friendly_id 5.0.0.rc3 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cc160c133d04de411d380863dcb8f5f6bf3d3eb
4
- data.tar.gz: 69989b70207313b3895dcb250dd28b9a5dd52503
3
+ metadata.gz: be471c9fdfbd158f951d1544207aa7adb87e0595
4
+ data.tar.gz: e2abb7c2074fbdfd5445e47e6ba01ae9a37a72d0
5
5
  SHA512:
6
- metadata.gz: 1de2c9b0aa51dca261d977bc4004d0f1d64e6f5f304e8e575ae2dc2c3e1fa1c24b780548729bd39685243f8190fa7fcf46de328f2d421b699c9e7fff75994d08
7
- data.tar.gz: e5d920ae4b3eed5a1d93c747dc1d1ef5ff91e930cb85d93b22197bcbc1274c43d4f882b3f57d91c7afc11186e737eac8183643fbc9e31a6c10eb3ca5243202b2
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
- "friendly_id" or "friendly-id" tag. Prior to asking, search and see if your
8
- question has already been anwered.
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.rc2' # Note: You MUST use 5.0.0 or greater for Rails 4.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
@@ -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)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module FriendlyId
2
- VERSION = "5.0.0.rc3"
2
+ VERSION = "5.0.0"
3
3
  end
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.rc3
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-04 00:00:00.000000000 Z
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: 1.3.1
218
+ version: '0'
219
219
  requirements: []
220
220
  rubyforge_project: friendly_id
221
221
  rubygems_version: 2.0.3