effective_slugs 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/app/models/concerns/acts_as_sluggable.rb +18 -2
- data/lib/effective_slugs/version.rb +1 -1
- data/lib/generators/templates/effective_slugs.rb +1 -1
- metadata +8 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca6f1bdd031ce20260513fdf6929663c8cbdedcf
|
4
|
+
data.tar.gz: cc5d68efab2b88fd6eabc3152a82b67da3398d3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b07e70814443dfc738592c659db45f70f94d34e8d4b9a40daab2af59b34550ee02217f6e631fb2f817d6f5124e2d7bb2103b57e1fbdec43829ed3c17cc165d9d
|
7
|
+
data.tar.gz: d79e02248e6300db36d7b9807c21e714a835fd8543588d93694c4957445646dd4afb75fd82fa4c5203e0b2b4628b79071dda53f1b20485b891dfb0680fc1565d
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Effective Slugs
|
2
2
|
|
3
|
-
Automatically generate URL-appropriate slugs when saving a record.
|
3
|
+
Automatically generate URL-appropriate slugs when saving a record.
|
4
4
|
|
5
|
-
Also overrides ActiveRecord .find()
|
5
|
+
Also overrides ActiveRecord's .find() method to accept the slug, or an id as the parameter.
|
6
6
|
|
7
|
-
Rails
|
7
|
+
Rails 3.2.x and Rails 4.
|
8
8
|
|
9
9
|
|
10
10
|
## Getting Started
|
@@ -72,7 +72,7 @@ def should_generate_new_slug?
|
|
72
72
|
end
|
73
73
|
```
|
74
74
|
|
75
|
-
The slug is generated based on
|
75
|
+
The slug is generated based on an object's `slug_source` method, which can also be overridden by adding the following to the model:
|
76
76
|
|
77
77
|
```ruby
|
78
78
|
def slug_source
|
@@ -67,7 +67,6 @@ module ActsAsSluggable
|
|
67
67
|
else
|
68
68
|
validates_uniqueness_of :slug
|
69
69
|
end
|
70
|
-
|
71
70
|
end
|
72
71
|
|
73
72
|
def set_slug
|
@@ -101,8 +100,25 @@ module ActsAsSluggable
|
|
101
100
|
end
|
102
101
|
|
103
102
|
def to_param
|
104
|
-
(slug.present? rescue false) ?
|
103
|
+
(slug.present? rescue false) ? slug_was : super
|
104
|
+
end
|
105
|
+
|
106
|
+
module ClassMethods
|
107
|
+
def relation
|
108
|
+
super.tap { |relation| relation.extend(FinderMethods) }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
module FinderMethods
|
113
|
+
def find(*args)
|
114
|
+
args.first.to_i > 0 ? super : find_by_slug(args)
|
115
|
+
end
|
116
|
+
|
117
|
+
def exists?(*args)
|
118
|
+
args.first.to_i > 0 ? super : (find_by_slug(args).present? rescue false)
|
119
|
+
end
|
105
120
|
end
|
106
121
|
|
122
|
+
|
107
123
|
end
|
108
124
|
|
metadata
CHANGED
@@ -1,31 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_slugs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
description: Automatically generate URL-appropriate slugs when saving a record.
|
28
|
-
3 only.
|
26
|
+
version: 3.2.0
|
27
|
+
description: Automatically generate URL-appropriate slugs when saving a record.
|
29
28
|
email:
|
30
29
|
- info@codeandeffect.com
|
31
30
|
executables: []
|
@@ -97,8 +96,7 @@ rubyforge_project:
|
|
97
96
|
rubygems_version: 2.4.3
|
98
97
|
signing_key:
|
99
98
|
specification_version: 4
|
100
|
-
summary: Automatically generate URL-appropriate slugs when saving a record.
|
101
|
-
3 only.
|
99
|
+
summary: Automatically generate URL-appropriate slugs when saving a record.
|
102
100
|
test_files:
|
103
101
|
- spec/dummy/app/assets/javascripts/application.js
|
104
102
|
- spec/dummy/app/assets/stylesheets/application.css
|