friendly_id 4.0.3 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.md CHANGED
@@ -6,6 +6,11 @@ suggestions, ideas and improvements to FriendlyId.
6
6
  * Table of Contents
7
7
  {:toc}
8
8
 
9
+ ## 4.0.4 (2012-03-26)
10
+
11
+ * Fix globalize plugin to avoid issues with asset precompilation (Philip Arndt)
12
+
13
+
9
14
  ## 4.0.3 (2012-03-14)
10
15
 
11
16
  * Fix escape for '%' and '_' on SQLite (Norman Clarke and Sergey Petrunin)
data/lib/friendly_id.rb CHANGED
@@ -45,7 +45,7 @@ with numeric ids:
45
45
  module FriendlyId
46
46
 
47
47
  # The current version.
48
- VERSION = "4.0.3"
48
+ VERSION = "4.0.4"
49
49
 
50
50
  @mutex = Mutex.new
51
51
 
@@ -60,13 +60,8 @@ assign a value to the +slug+ field:
60
60
  relation_class.send :include, FinderMethods
61
61
  include Model
62
62
  # Check if slug field is enabled to be translated with Globalize
63
- if table_exists?
64
- if columns.map(&:name).exclude?(friendly_id_config.query_field)
65
- puts "\n[FriendlyId] Missing field '#{friendly_id_config.query_field}' in DB table '#{table_name}'. This is required for FriendlyId to properly function with the :globalize option.\n\n"
66
- end
67
- unless respond_to?('translated_attribute_names') || translated_attribute_names.exclude?(friendly_id_config.query_field.to_sym)
68
- puts "\n[FriendlyId] You need to translate '#{friendly_id_config.query_field}' field with Globalize (add 'translates :#{friendly_id_config.query_field}' in your model '#{self.class.name}')\n\n"
69
- end
63
+ unless respond_to?('translated_attribute_names') || translated_attribute_names.exclude?(friendly_id_config.query_field.to_sym)
64
+ puts "\n[FriendlyId] You need to translate '#{friendly_id_config.query_field}' field with Globalize (add 'translates :#{friendly_id_config.query_field}' in your model '#{self.class.name}')\n\n"
70
65
  end
71
66
  end
72
67
  end
@@ -197,13 +197,13 @@ issue}[https://github.com/norman/friendly_id/issues/180] for discussion.
197
197
  # Sets up behavior and configuration options for FriendlyId's slugging
198
198
  # feature.
199
199
  def self.included(model_class)
200
- model_class.instance_eval do
201
- friendly_id_config.class.send :include, Configuration
202
- friendly_id_config.defaults[:slug_column] ||= 'slug'
203
- friendly_id_config.defaults[:sequence_separator] ||= '--'
204
- friendly_id_config.slug_generator_class ||= Class.new(SlugGenerator)
205
- before_validation :set_slug
200
+ model_class.friendly_id_config.instance_eval do
201
+ self.class.send :include, Configuration
202
+ self.slug_generator_class ||= Class.new(SlugGenerator)
203
+ defaults[:slug_column] ||= 'slug'
204
+ defaults[:sequence_separator] ||= '--'
206
205
  end
206
+ model_class.before_validation :set_slug
207
207
  end
208
208
 
209
209
  # Process the given value to make it suitable for use as a slug.
@@ -252,10 +252,17 @@ issue}[https://github.com/norman/friendly_id/issues/180] for discussion.
252
252
  def should_generate_new_friendly_id?
253
253
  base = send(friendly_id_config.base)
254
254
  slug_value = send(friendly_id_config.slug_column)
255
+
256
+ # If the slug base is nil, and the slug field is nil, then we're going to
257
+ # leave the slug column NULL.
255
258
  return false if base.nil? && slug_value.nil?
259
+ # Otherwise, if this is a new record, we're definitely going to try to
260
+ # create a new slug.
256
261
  return true if new_record?
257
262
  slug_base = normalize_friendly_id(base)
258
263
  separator = Regexp.escape friendly_id_config.sequence_separator
264
+ # If the slug base (without sequence) is different from either the current
265
+ # friendly id or the slug value, then we'll generate a new friendly_id.
259
266
  slug_base != (current_friendly_id || slug_value).try(:sub, /#{separator}[\d]*\z/, '')
260
267
  end
261
268
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friendly_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-14 00:00:00.000000000 Z
12
+ date: 2012-03-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &70135168764860 !ruby/object:Gem::Requirement
16
+ requirement: &70338516662860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.2.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70135168764860
24
+ version_requirements: *70338516662860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord
27
- requirement: &70135168764100 !ruby/object:Gem::Requirement
27
+ requirement: &70338516662240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.2.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70135168764100
35
+ version_requirements: *70338516662240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitest
38
- requirement: &70135168763460 !ruby/object:Gem::Requirement
38
+ requirement: &70338516661800 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70135168763460
46
+ version_requirements: *70338516661800
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mocha
49
- requirement: &70135171790060 !ruby/object:Gem::Requirement
49
+ requirement: &70338516694440 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70135171790060
57
+ version_requirements: *70338516694440
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: maruku
60
- requirement: &70135171789640 !ruby/object:Gem::Requirement
60
+ requirement: &70338516692760 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70135171789640
68
+ version_requirements: *70338516692760
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
- requirement: &70135171789220 !ruby/object:Gem::Requirement
71
+ requirement: &70338516724120 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70135171789220
79
+ version_requirements: *70338516724120
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: i18n
82
- requirement: &70135171788800 !ruby/object:Gem::Requirement
82
+ requirement: &70338516719100 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70135171788800
90
+ version_requirements: *70338516719100
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: ffaker
93
- requirement: &70135171788380 !ruby/object:Gem::Requirement
93
+ requirement: &70338516717320 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70135171788380
101
+ version_requirements: *70338516717320
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: simplecov
104
- requirement: &70135171787960 !ruby/object:Gem::Requirement
104
+ requirement: &70338516730820 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70135171787960
112
+ version_requirements: *70338516730820
113
113
  description: ! 'FriendlyId is the "Swiss Army bulldozer" of slugging and permalink
114
114
  plugins for
115
115