friendly_id_globalize3 3.2.1.5 → 3.2.1.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -61,8 +61,12 @@ module FriendlyId
|
|
61
61
|
def find_one_with_slug
|
62
62
|
sluggable_ids = sluggable_ids_for([id])
|
63
63
|
|
64
|
-
if sluggable_ids.
|
65
|
-
|
64
|
+
if sluggable_ids.many? && fc.scope?
|
65
|
+
if relation.primary_key.respond_to?(:in)
|
66
|
+
return relation.where(relation.primary_key.in(sluggable_ids)).first
|
67
|
+
else
|
68
|
+
return relation.where(relation.primary_key => sluggable_ids).first
|
69
|
+
end
|
66
70
|
end
|
67
71
|
|
68
72
|
sluggable_id = sluggable_ids.first
|
@@ -83,7 +87,12 @@ module FriendlyId
|
|
83
87
|
return find_some_using_slug(friendly_ids, unfriendly_ids) if use_slugs_table
|
84
88
|
column = fc.cache_column || fc.column
|
85
89
|
friendly = arel_table[column].in(friendly_ids)
|
86
|
-
unfriendly =
|
90
|
+
unfriendly = if relation.primary_key.respond_to?(:name)
|
91
|
+
arel_table[relation.primary_key.name].in unfriendly_ids
|
92
|
+
else
|
93
|
+
arel_table[relation.primary_key].in unfriendly_ids
|
94
|
+
end
|
95
|
+
|
87
96
|
if friendly_ids.present? && unfriendly_ids.present?
|
88
97
|
where(friendly.or(unfriendly))
|
89
98
|
else
|
@@ -93,7 +102,11 @@ module FriendlyId
|
|
93
102
|
|
94
103
|
def find_some_using_slug(friendly_ids, unfriendly_ids)
|
95
104
|
ids = [unfriendly_ids + sluggable_ids_for(friendly_ids)].flatten.uniq
|
96
|
-
|
105
|
+
if relation.primary_key.respond_to?(:name)
|
106
|
+
where(arel_table[relation.primary_key.name].in(ids))
|
107
|
+
else
|
108
|
+
where(arel_table[relation.primary_key].in(ids))
|
109
|
+
end
|
97
110
|
end
|
98
111
|
|
99
112
|
def sluggable_ids_for(ids)
|
@@ -9,9 +9,8 @@ class Slug < ::ActiveRecord::Base
|
|
9
9
|
named_scope :similar_to, lambda {|slug| {:conditions => {
|
10
10
|
:name => slug.name,
|
11
11
|
:scope => slug.scope,
|
12
|
-
:locale => slug.locale,
|
13
12
|
:sluggable_type => slug.sluggable_type
|
14
|
-
},
|
13
|
+
}.merge(({:locale => slug.locale} if slug.respond_to?(:locale)) || {}),
|
15
14
|
:order => "sequence ASC"
|
16
15
|
}
|
17
16
|
}
|
@@ -15,6 +15,18 @@ module FriendlyId
|
|
15
15
|
after_update :update_dependent_scopes
|
16
16
|
protect_friendly_id_attributes
|
17
17
|
extend FriendlyId::ActiveRecordAdapter::Finders unless FriendlyId.on_ar3?
|
18
|
+
def slug_with_rails_3_2_patch
|
19
|
+
unless (_slug = slug_without_rails_3_2_patch)
|
20
|
+
_slug = if friendly_id_config.class.locales_used?
|
21
|
+
slugs.where(:locale => (Thread.current[:globalize_locale] || ::I18n.locale)).first
|
22
|
+
else
|
23
|
+
slugs.first
|
24
|
+
end
|
25
|
+
end
|
26
|
+
_slug
|
27
|
+
end
|
28
|
+
alias_method_chain :slug, :rails_3_2_patch
|
29
|
+
|
18
30
|
end
|
19
31
|
end
|
20
32
|
|
data/lib/friendly_id/version.rb
CHANGED
metadata
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: friendly_id_globalize3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 103
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 2
|
9
9
|
- 1
|
10
|
-
-
|
11
|
-
version: 3.2.1.
|
10
|
+
- 6
|
11
|
+
version: 3.2.1.6
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Norman Clarke
|
15
15
|
- Adrian Mugnolo
|
16
16
|
- Emilio Tagua
|
17
|
+
- Philip Arndt
|
17
18
|
autorequire:
|
18
19
|
bindir: bin
|
19
20
|
cert_chain: []
|
20
21
|
|
21
|
-
date:
|
22
|
+
date: 2012-01-24 00:00:00 Z
|
22
23
|
dependencies:
|
23
24
|
- !ruby/object:Gem::Dependency
|
24
25
|
name: babosa
|
@@ -81,11 +82,28 @@ dependencies:
|
|
81
82
|
version: "1.3"
|
82
83
|
type: :development
|
83
84
|
version_requirements: *id004
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: rake
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 63
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
- 9
|
97
|
+
- 2
|
98
|
+
version: 0.9.2
|
99
|
+
type: :development
|
100
|
+
version_requirements: *id005
|
84
101
|
description: " FriendlyId is the \"Swiss Army bulldozer\" of slugging and permalink plugins\n for Ruby on Rails. It allows you to create pretty URL's and work with\n human-friendly strings as if they were numeric ids for ActiveRecord models.\n"
|
85
102
|
email:
|
86
103
|
- norman@njclarke.com
|
87
104
|
- adrian@mugnolo.com
|
88
105
|
- miloops@gmail.com
|
106
|
+
- parndt@gmail.com
|
89
107
|
executables: []
|
90
108
|
|
91
109
|
extensions: []
|