withardry 0.2.0 → 0.2.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.md +12 -5
- data/lib/withardry/base.rb +1 -1
- data/lib/withardry/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## Install
|
4
4
|
|
5
|
-
gem "withardry"
|
5
|
+
gem "withardry"
|
6
6
|
|
7
7
|
## Usage
|
8
8
|
|
@@ -10,7 +10,7 @@
|
|
10
10
|
withardry :title
|
11
11
|
|
12
12
|
# exactly same as
|
13
|
-
#
|
13
|
+
# scope :with_title, lambda { |t| where(:title => t) }
|
14
14
|
|
15
15
|
friendly_url
|
16
16
|
# same as to_param with model id and name attribute
|
@@ -22,7 +22,9 @@
|
|
22
22
|
Now use this inside your app:
|
23
23
|
|
24
24
|
Post.with_title("Some title")
|
25
|
-
|
25
|
+
|
26
|
+
post = Post.create(:title => "Title Example")
|
27
|
+
post.to_param # => "1-title-example"
|
26
28
|
|
27
29
|
Sure, it can handle some options
|
28
30
|
|
@@ -32,7 +34,7 @@ Sure, it can handle some options
|
|
32
34
|
withardry :user, :prefix => "by", :as => "user_id"
|
33
35
|
|
34
36
|
// exactly same as
|
35
|
-
//
|
37
|
+
// scope :by_user, lambda {|u| where(:user_id => u) }
|
36
38
|
end
|
37
39
|
|
38
40
|
And then anywhere in your app
|
@@ -41,7 +43,12 @@ And then anywhere in your app
|
|
41
43
|
|
42
44
|
## Contributors
|
43
45
|
|
44
|
-
- Ognevsky
|
46
|
+
- [Andrey Ognevsky](https://github.com/ognevsky), [Evrone Company](https://github.com/evrone)
|
45
47
|
- [Kirill Shatrov](https://github.com/kirs/), [Evrone Company](https://github.com/evrone)
|
46
48
|
|
49
|
+
## Todo
|
50
|
+
|
51
|
+
- Ensure that tests work with Rails 3
|
52
|
+
- Add support of relations in withardry method (e.g. use of `withardry :user` is equal to `withardry :user_id` if there is a relation with User)
|
53
|
+
|
47
54
|
## Feel free for pull requests
|
data/lib/withardry/base.rb
CHANGED
@@ -14,7 +14,7 @@ module Withardry
|
|
14
14
|
define_method(:to_param) do
|
15
15
|
attribute = self.send(field)
|
16
16
|
stack = [id.to_s]
|
17
|
-
stack <<
|
17
|
+
stack << attribute.parameterize if attribute.present?
|
18
18
|
stack.join("-")
|
19
19
|
end
|
20
20
|
end
|
data/lib/withardry/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: withardry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-11-
|
13
|
+
date: 2011-11-03 00:00:00.000000000Z
|
14
14
|
dependencies: []
|
15
15
|
description: ''
|
16
16
|
email:
|