couchrest_model_slug 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.
- data/README.rdoc +53 -2
- data/lib/couchrest/model/slug/version.rb +1 -1
- metadata +5 -5
data/README.rdoc
CHANGED
@@ -1,3 +1,54 @@
|
|
1
|
-
|
1
|
+
== CouchRest Model Slug
|
2
2
|
|
3
|
-
|
3
|
+
CouchRest Model Slug is a simple gem to generate better urls using CouchRest Model in an easy way.
|
4
|
+
It's based on Mongoid Slug https://github.com/papercavalier/mongoid-slug
|
5
|
+
|
6
|
+
Time to relax with beautiful urls.
|
7
|
+
|
8
|
+
== Getting Started
|
9
|
+
|
10
|
+
Add to Gemfile
|
11
|
+
|
12
|
+
gem "couchrest_model_slug", "~> 0.0.1"
|
13
|
+
|
14
|
+
A model example
|
15
|
+
|
16
|
+
class Post < CouchRest::Model::Base
|
17
|
+
include CouchRest::Model::Slug
|
18
|
+
|
19
|
+
property :title
|
20
|
+
property :summary
|
21
|
+
property :text
|
22
|
+
|
23
|
+
slug :title, :summary
|
24
|
+
end
|
25
|
+
|
26
|
+
It's all you need to get things working =)
|
27
|
+
|
28
|
+
== Querying
|
29
|
+
|
30
|
+
p = Post.create(:title => "CouchDB", :summary => "Time to relax!")
|
31
|
+
p.to_param # => "couchdb-time-to-relax"
|
32
|
+
|
33
|
+
Post.find("couchdb-time-to-relax") # =>#<Post slug: "couchdb-time-to-relax", title: "CouchDB"...
|
34
|
+
|
35
|
+
== Special feature
|
36
|
+
|
37
|
+
CouchRest Model Slug was made to work with or without slugged value, then it uses the id to keep things running with no problems.
|
38
|
+
|
39
|
+
Post.create(:text => "post without slug") # => #<Post slug: "", title: nil, summary: nil, text: "post with no slug", _id: "9fdfdd090897680de59091c8c98ff064"...
|
40
|
+
|
41
|
+
Post.find("9fdfdd090897680de59091c8c98ff064") # => #<Post slug: "", title: nil, summary: nil, text: "post with no slug", _id: "9fdfdd090897680de59091c8c98ff064"...
|
42
|
+
|
43
|
+
== Notes
|
44
|
+
|
45
|
+
CouchRest Model Slug automatically adds a property called slug into your model to store the slugged value.
|
46
|
+
Then you can call the slug property directly.
|
47
|
+
|
48
|
+
p = Post.create(:title => "CouchDB", :summary => "Time to relax!")
|
49
|
+
p.slug # => "couchdb-time-to-relax"
|
50
|
+
|
51
|
+
If you want to be more explicit, you can query using find_by_slug magic method:
|
52
|
+
|
53
|
+
Post.find_by_slug("couchdb-time-to-relax") # =>#<Post slug: "couchdb-time-to-relax", title: "CouchDB"...
|
54
|
+
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: couchrest_model_slug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Lucas Renan
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-25 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: couchrest_model
|
@@ -18,9 +18,9 @@ dependencies:
|
|
18
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.1.0
|
23
|
+
version: 1.1.0
|
24
24
|
type: :runtime
|
25
25
|
version_requirements: *id001
|
26
26
|
- !ruby/object:Gem::Dependency
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
requirement: &id002 !ruby/object:Gem::Requirement
|
30
30
|
none: false
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 1.2.1
|
35
35
|
type: :runtime
|