friendly_id 4.0.10 → 4.0.10.1
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/Gemfile +1 -1
- data/Guide.rdoc +42 -16
- data/README.md +3 -3
- data/friendly_id.gemspec +2 -2
- data/lib/friendly_id/version.rb +2 -2
- metadata +17 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fbc5031a53b7d9a5ccd504f5ae0320b438ae54c
|
4
|
+
data.tar.gz: 4762396921c1d48229e84b3a2c3641a0910606e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 626640c8d2daadc57079407bed1e692caf7c3e0c7f7768a8cab195cfbe1d274d0f0220cea71c5413f0293174ba769fb6e809f537e34285717aed4fb2f3d171c2
|
7
|
+
data.tar.gz: e27071a087add84317bcc85be519d070e00e9ada3fe77cc123234bbd4ac33cff258cb41bed593d9cca01330ab80f217bde9765720cc5d77187f7aa6e6341cb82
|
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.10.1 (2013-08-20)
|
10
|
+
|
11
|
+
* Update dependencies in gemspec to avoid using with Active Record 4.
|
12
|
+
* Fixed links in docs.
|
13
|
+
|
9
14
|
## 4.0.10 (2013-08-10)
|
10
15
|
|
11
16
|
* Fixed table prefixes/suffixes being ignored (Jesse Farless)
|
data/Gemfile
CHANGED
data/Guide.rdoc
CHANGED
@@ -114,9 +114,8 @@ store them in a field in your model. By default, this field must be named
|
|
114
114
|
+:slug+, though you may change this using the
|
115
115
|
{FriendlyId::Slugged::Configuration#slug_column slug_column} configuration
|
116
116
|
option. You should add an index to this column, and in most cases, make it
|
117
|
-
unique.
|
118
|
-
|
119
|
-
depends on your app's behavior and requirements.
|
117
|
+
unique. You may also wish to constrain it to NOT NULL, but this depends on your
|
118
|
+
app's behavior and requirements.
|
120
119
|
|
121
120
|
=== Example Setup
|
122
121
|
|
@@ -357,8 +356,27 @@ Without :scoped in this case, one of the restaurants would have the slug
|
|
357
356
|
The value for the +:scope+ option can be the name of a +belongs_to+ relation, or
|
358
357
|
a column.
|
359
358
|
|
360
|
-
|
361
|
-
|
359
|
+
Additionally, the +:scope+ option can receive an array of scope values:
|
360
|
+
|
361
|
+
class Cuisine < ActiveRecord::Base
|
362
|
+
extend FriendlyId
|
363
|
+
has_many :restaurants
|
364
|
+
friendly_id :name, :use => :slugged
|
365
|
+
end
|
366
|
+
|
367
|
+
class City < ActiveRecord::Base
|
368
|
+
extend FriendlyId
|
369
|
+
has_many :restaurants
|
370
|
+
friendly_id :name, :use => :slugged
|
371
|
+
end
|
372
|
+
|
373
|
+
class Restaurant < ActiveRecord::Base
|
374
|
+
extend FriendlyId
|
375
|
+
belongs_to :city
|
376
|
+
friendly_id :name, :use => :scoped, :scope => [:city, :cuisine]
|
377
|
+
end
|
378
|
+
|
379
|
+
All supplied values will be used to determine scope.
|
362
380
|
|
363
381
|
=== Finding Records by Friendly ID
|
364
382
|
|
@@ -467,7 +485,7 @@ If you don't pass in a locale argument, FriendlyId::SimpleI18n will just use the
|
|
467
485
|
current locale:
|
468
486
|
|
469
487
|
I18n.with_locale(:es) do
|
470
|
-
post.set_friendly_id("
|
488
|
+
post.set_friendly_id("La guerra de las galaxas")
|
471
489
|
end
|
472
490
|
|
473
491
|
|
@@ -499,12 +517,15 @@ Finds will take the current locale into consideration:
|
|
499
517
|
I18n.locale = :en
|
500
518
|
Post.find("star-wars")
|
501
519
|
|
520
|
+
Additionally, finds will fall back to the default locale:
|
521
|
+
|
522
|
+
I18n.locale = :it
|
523
|
+
Post.find("star-wars")
|
524
|
+
|
502
525
|
To find a slug by an explicit locale, perform the find inside a block
|
503
526
|
passed to I18n's +with_locale+ method:
|
504
527
|
|
505
|
-
I18n.with_locale(:it)
|
506
|
-
Post.find("guerre-stellari")
|
507
|
-
end
|
528
|
+
I18n.with_locale(:it) { Post.find("guerre-stellari") }
|
508
529
|
|
509
530
|
=== Creating Records
|
510
531
|
|
@@ -512,12 +533,17 @@ When new records are created, the slug is generated for the current locale only.
|
|
512
533
|
|
513
534
|
=== Translating Slugs
|
514
535
|
|
515
|
-
To translate an existing record's friendly_id,
|
516
|
-
|
536
|
+
To translate an existing record's friendly_id, use
|
537
|
+
{FriendlyId::Globalize::Model#set_friendly_id}. This will ensure that the slug
|
538
|
+
you add is properly escaped, transliterated and sequenced:
|
517
539
|
|
518
|
-
|
519
|
-
|
520
|
-
|
540
|
+
post = Post.create :name => "Star Wars"
|
541
|
+
post.set_friendly_id("Guerre stellari", :it)
|
542
|
+
|
543
|
+
If you don't pass in a locale argument, FriendlyId::Globalize will just use the
|
544
|
+
current locale:
|
545
|
+
|
546
|
+
I18n.with_locale(:it) { post.set_friendly_id("Guerre stellari") }
|
521
547
|
|
522
548
|
|
523
549
|
== Reserved Words
|
@@ -548,6 +574,6 @@ For example:
|
|
548
574
|
after_validation :move_friendly_id_error_to_name
|
549
575
|
|
550
576
|
def move_friendly_id_error_to_name
|
551
|
-
errors.
|
577
|
+
errors.add :name, *errors.delete(:friendly_id) if errors[:friendly_id].present?
|
552
578
|
end
|
553
|
-
end
|
579
|
+
end
|
data/README.md
CHANGED
@@ -27,16 +27,16 @@ FriendlyId is compatible with Active Record **3.0** and higher.
|
|
27
27
|
|
28
28
|
FriendlyId 4.x introduces many changes incompatible with 3.x. If you're
|
29
29
|
upgrading, please [read the
|
30
|
-
docs](http://rubydoc.info/github/
|
30
|
+
docs](http://rubydoc.info/github/norman/friendly_id/4.0-stable/file/WhatsNew.md) to see what's
|
31
31
|
new.
|
32
32
|
|
33
33
|
## Docs
|
34
34
|
|
35
35
|
The current docs can always be found
|
36
|
-
[here](http://rubydoc.info/github/
|
36
|
+
[here](http://rubydoc.info/github/norman/friendly_id/4.0-stable/frames).
|
37
37
|
|
38
38
|
The best place to start is with the
|
39
|
-
[Guide](http://rubydoc.info/github/
|
39
|
+
[Guide](http://rubydoc.info/github/norman/friendly_id/4.0-stable/file/Guide.rdoc),
|
40
40
|
which compiles the top-level RDocs into one outlined document.
|
41
41
|
|
42
42
|
You might also want to watch Ryan Bates's [Railscast on FriendlyId](http://railscasts.com/episodes/314-pretty-urls-with-friendlyid).
|
data/friendly_id.gemspec
CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
15
15
|
s.require_paths = ["lib"]
|
16
16
|
|
17
|
-
s.
|
18
|
-
s.add_development_dependency "
|
17
|
+
s.add_dependency "activerecord", ">= 3.0", "< 4.0"
|
18
|
+
s.add_development_dependency "railties", ">= 3.0", "< 4.0"
|
19
19
|
s.add_development_dependency "minitest", "~> 4.4.0"
|
20
20
|
s.add_development_dependency "mocha", "~> 0.13.1"
|
21
21
|
s.add_development_dependency "maruku"
|
data/lib/friendly_id/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module FriendlyId
|
2
|
-
VERSION = "4.0.10"
|
3
|
-
end
|
2
|
+
VERSION = "4.0.10.1"
|
3
|
+
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: 4.0.10
|
4
|
+
version: 4.0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Norman Clarke
|
@@ -9,29 +9,38 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: activerecord
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
18
|
- - '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '3.0'
|
21
|
-
|
21
|
+
- - <
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '4.0'
|
24
|
+
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
28
|
- - '>='
|
26
29
|
- !ruby/object:Gem::Version
|
27
30
|
version: '3.0'
|
31
|
+
- - <
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
35
|
+
name: railties
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
31
37
|
requirements:
|
32
38
|
- - '>='
|
33
39
|
- !ruby/object:Gem::Version
|
34
40
|
version: '3.0'
|
41
|
+
- - <
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '4.0'
|
35
44
|
type: :development
|
36
45
|
prerelease: false
|
37
46
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -39,6 +48,9 @@ dependencies:
|
|
39
48
|
- - '>='
|
40
49
|
- !ruby/object:Gem::Version
|
41
50
|
version: '3.0'
|
51
|
+
- - <
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '4.0'
|
42
54
|
- !ruby/object:Gem::Dependency
|
43
55
|
name: minitest
|
44
56
|
requirement: !ruby/object:Gem::Requirement
|