slugable-joe 0.0.1 → 0.0.2
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 +8 -8
- data/lib/slugable.rb +18 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTY2MTA5N2FiZmI5Y2ZhOWVkOWI0Y2YyZTgyNmRkNmFkYTIxMWZiYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MGExZjgzMjRlODg2NTk3OGViYWEyNjEyNzUxN2JiZWQzNjQxMmM4ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWUyNWRhNGM1NmI1ZDc4OWQ5YmJjNjQ5MTk5NjI2MDIxYmMzZTc1NTUzYTAw
|
10
|
+
MzQxMzBiYmU5YTg0NzE0MTc2OTg1ZjUxYWQ0ZGNkN2QzY2UxMjE3MzdmYzNk
|
11
|
+
YTFkZmI1ZDU2ZmMzOTQzN2JiMDljZDRiNzcxNWUzZjlmYThhMDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTZmNDQyMWIwNTgxNjVjM2ExNGQ3MjFiYWE0NGIyZWE4ODUwOWZiYTdkMDhh
|
14
|
+
NGM4YmNlZWNkYWRkOGIzZjQyYTZmMjQyNWQ2YmM2ODM1ODVmOTgxOTVjNGIw
|
15
|
+
NzlkMjlmNWRiZmQ2M2M0ODQ4ZjU4NzBjMDczYjAzYzk4YjMxNzk=
|
data/lib/slugable.rb
CHANGED
@@ -1,7 +1,23 @@
|
|
1
1
|
# Note:
|
2
|
-
#
|
3
|
-
# will
|
2
|
+
#
|
3
|
+
# You will need to include three items in your code in order for the gem to work properly:
|
4
|
+
#
|
5
|
+
# (1) Specify the :slug_string using the alias_attribute method. So, for example, if the
|
6
|
+
# slug that you are creating will be based on the :title in your model, you will need to
|
7
|
+
# include the following line of code within the file that is invoking the gem:
|
4
8
|
# alias_attribute :slug_string, :title
|
9
|
+
#
|
10
|
+
# (2) You will need to include a to_param method, in order to generate the slug, as follows:
|
11
|
+
#
|
12
|
+
# def to_param
|
13
|
+
# self.slug
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# You can then reference to_param in your view to print out the URL containing the slug.
|
17
|
+
#
|
18
|
+
# (3) You will want to use the before_save ActiveRecord Callback, as follows:
|
19
|
+
#
|
20
|
+
# before_save :generate_slug
|
5
21
|
|
6
22
|
module Slugable
|
7
23
|
def generate_slug
|