friendly_id 5.0.0.rc3 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog.md +5 -0
- data/README.md +3 -3
- data/lib/friendly_id/finders.rb +12 -0
- data/lib/friendly_id/scoped.rb +4 -0
- data/lib/friendly_id/version.rb +1 -1
- data/test/scoped_test.rb +9 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be471c9fdfbd158f951d1544207aa7adb87e0595
|
4
|
+
data.tar.gz: e2abb7c2074fbdfd5445e47e6ba01ae9a37a72d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d97900b4d53ef7d02a48665386e97bee42b2aceed5283209246bdc249e2467d40268b08bde9805bc3d0aa7d78eac9500ad83ff39302d6c43df804f298b0cf86e
|
7
|
+
data.tar.gz: 661f24ec624dcca17544c5ccf72cb708f8261fc31f06312110c44a6aafbb47c30f56068a8e38c77df2115d875839a6be100818b73beec7f4f74070bbb6565995
|
data/Changelog.md
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
We would like to think our many {file:Contributors contributors} for
|
4
4
|
suggestions, ideas and improvements to FriendlyId.
|
5
5
|
|
6
|
+
## 5.0.0 (2013-10-16)
|
7
|
+
|
8
|
+
* Fix to let scoped records reuse their slugs (thanks [Donny
|
9
|
+
Kurnia](https://github.com/donnykurnia)).
|
10
|
+
|
6
11
|
## 5.0.0.rc.3 (2013-10-04)
|
7
12
|
|
8
13
|
* Support friendly finds on associations in Rails 4.0.1 and up. They will
|
data/README.md
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
|
5
5
|
Please ask questions on [Stack
|
6
6
|
Overflow](http://stackoverflow.com/questions/tagged/friendly-id) using the
|
7
|
-
"
|
8
|
-
|
7
|
+
"friendly-id" tag. Prior to asking, search and see if your question has
|
8
|
+
already been anwered.
|
9
9
|
|
10
10
|
Please only post issues in Github issues for actual bugs.
|
11
11
|
|
@@ -163,7 +163,7 @@ cd my_app
|
|
163
163
|
```
|
164
164
|
```ruby
|
165
165
|
# Gemfile
|
166
|
-
gem 'friendly_id', '5.0.0
|
166
|
+
gem 'friendly_id', '~> 5.0.0' # Note: You MUST use 5.0.0 or greater for Rails 4.0+
|
167
167
|
```
|
168
168
|
```shell
|
169
169
|
rails generate friendly_id
|
data/lib/friendly_id/finders.rb
CHANGED
@@ -49,6 +49,18 @@ in your controllers to use the `friendly` scope. For example:
|
|
49
49
|
def set_restaurant
|
50
50
|
@restaurant = Restaurant.friendly.find(params[:id])
|
51
51
|
end
|
52
|
+
|
53
|
+
#### Active Admin
|
54
|
+
|
55
|
+
Unless you use the `:finders` addon, you should modify your admin controllers
|
56
|
+
for models that use FriendlyId with something similar to the following:
|
57
|
+
|
58
|
+
controller do
|
59
|
+
def find_resource
|
60
|
+
scoped_collection.friendly.find(params[:id])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
52
64
|
=end
|
53
65
|
module Finders
|
54
66
|
def self.included(model_class)
|
data/lib/friendly_id/scoped.rb
CHANGED
@@ -126,6 +126,10 @@ an example of one way to set this up:
|
|
126
126
|
friendly_id_config.scope_columns.each do |column|
|
127
127
|
relation = relation.where(column => send(column))
|
128
128
|
end
|
129
|
+
if changed.include?(friendly_id_config.slug_column)
|
130
|
+
column = self.class.quoted_table_name + '.' + self.class.quoted_primary_key
|
131
|
+
relation = relation.where("#{column} <> ?", send(self.class.primary_key))
|
132
|
+
end
|
129
133
|
friendly_id_config.slug_generator_class.new(relation)
|
130
134
|
end
|
131
135
|
private :slug_generator
|
data/lib/friendly_id/version.rb
CHANGED
data/test/scoped_test.rb
CHANGED
@@ -69,4 +69,13 @@ class ScopedTest < MiniTest::Unit::TestCase
|
|
69
69
|
assert novel3.friendly_id != novel4.friendly_id
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
test 'should allow a record to reuse its own slug' do
|
74
|
+
with_instance_of(model_class) do |record|
|
75
|
+
old_id = record.friendly_id
|
76
|
+
record.slug = nil
|
77
|
+
record.save!
|
78
|
+
assert_equal old_id, record.friendly_id
|
79
|
+
end
|
80
|
+
end
|
72
81
|
end
|
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: 5.0.0
|
4
|
+
version: 5.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Norman Clarke
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -213,9 +213,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
213
213
|
version: 1.9.3
|
214
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
215
|
requirements:
|
216
|
-
- - '
|
216
|
+
- - '>='
|
217
217
|
- !ruby/object:Gem::Version
|
218
|
-
version:
|
218
|
+
version: '0'
|
219
219
|
requirements: []
|
220
220
|
rubyforge_project: friendly_id
|
221
221
|
rubygems_version: 2.0.3
|