acts_as_permalink 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.markdown +59 -30
- data/lib/acts_as_permalink/version.rb +1 -1
- metadata +31 -30
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 190594fc3346f8fd08fb3230464ca3de803c5d97
|
4
|
+
data.tar.gz: 7eb39d42f85095d85ade06cc2a6e07d05ae4b3a9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4b3d28c4da66a76351e29cb9006c508f89dde1165eec32130e6fccaa70dd4d9cacad09450af84b6b8ec88ad8d0660a33c94661c2ecaaa1843b64395c84aa69ef
|
7
|
+
data.tar.gz: e782467bd4519a071e15ab29ee3639dc01d8f242b231ad8282340433f498c13f1ac28bcac86febd721f7a126529a44c5744b3f78a65885e6ea2b9e0fe123ec3d
|
data/README.markdown
CHANGED
@@ -1,58 +1,87 @@
|
|
1
|
-
# Acts
|
1
|
+
# [Acts as Permalink](https://github.com/kmcphillips/acts_as_permalink)
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/kmcphillips/acts_as_permalink.svg?branch=master)](https://travis-ci.org/kmcphillips/acts_as_permalink)
|
2
4
|
|
3
5
|
Manages permalink field on an ActiveRecord model to be used in place of the id field in Rails.
|
4
6
|
|
5
|
-
Written by Kevin McPhillips
|
7
|
+
Written by [Kevin McPhillips](https://github.com/kmcphillips) ([github@kevinmcphillips.ca](mailto:github@kevinmcphillips.ca))
|
6
8
|
|
7
|
-
Last updated March 2012.
|
8
9
|
|
9
|
-
|
10
|
+
## Installation
|
10
11
|
|
11
|
-
|
12
|
+
Using bundler, add to the Gemfile:
|
12
13
|
|
14
|
+
```ruby
|
15
|
+
gem 'acts_as_permalink'
|
16
|
+
```
|
13
17
|
|
14
|
-
|
18
|
+
Or stand alone:
|
15
19
|
|
16
|
-
|
20
|
+
```
|
21
|
+
$ gem install acts_as_permalink
|
22
|
+
```
|
17
23
|
|
18
|
-
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
This gem works with ActiveRecord, and by convention looks for a `title` method and a `permalink` string field on the model:
|
19
27
|
|
20
28
|
And then just call it in your model:
|
21
29
|
|
22
|
-
|
23
|
-
|
24
|
-
|
30
|
+
```ruby
|
31
|
+
class Post < ActiveRecord::Base
|
32
|
+
acts_as_permalink
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
You can then use your link helpers normally:
|
25
37
|
|
26
|
-
|
27
|
-
|
38
|
+
```ruby
|
39
|
+
post_path(@post) # "/post/the_name_of_post_here"
|
40
|
+
```
|
28
41
|
|
29
|
-
|
30
|
-
:to => :permalink # Name of the column where the permalink will be stored
|
31
|
-
:max_length => 60 # Maximum number of characters the permalink will be
|
42
|
+
The `title` and `permalink` fields can be overridden with the following options:
|
32
43
|
|
33
|
-
|
44
|
+
from: :title # Name of the active record column or function used to generate the permalink
|
45
|
+
to: :permalink # Name of the column where the permalink will be stored
|
46
|
+
max_length: 60 # Maximum number of characters the permalink will be
|
34
47
|
|
35
|
-
|
36
|
-
acts_as_permalink :from => :full_name, :to => :path, :max_length => 40
|
48
|
+
So, for example you have want to store your permalink in a column called `path_name` and you want to generate your permalink using first and last name, and you want to restrict it to 40 characters, your model would look like:
|
37
49
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
50
|
+
```ruby
|
51
|
+
class User < ActiveRecord::Base
|
52
|
+
acts_as_permalink from: :full_name, to: :path, max_length: 40
|
53
|
+
|
54
|
+
def full_name
|
55
|
+
[first_name, last_name].join(" ")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
```
|
42
59
|
|
43
60
|
|
44
61
|
## Tests
|
45
62
|
|
46
|
-
|
47
|
-
|
48
|
-
|
63
|
+
```
|
64
|
+
$ bundle exec rspec
|
65
|
+
```
|
66
|
+
|
67
|
+
|
68
|
+
## Changelog
|
69
|
+
|
70
|
+
* 0.4.1 -- Documentation improvements.
|
71
|
+
|
72
|
+
* 0.4.0 -- Rails 4 support.
|
49
73
|
|
74
|
+
* 0.3.2 -- Fixed regression in STI support.
|
50
75
|
|
51
|
-
|
76
|
+
* 0.3.1 -- Rails 3.2 support.
|
52
77
|
|
53
|
-
*
|
78
|
+
* 0.3.0 -- Fixed collision problem with single table inheritance models. Removed dependency on andand gem.
|
54
79
|
|
55
|
-
* March 19, 2012 -- Updated to work with Rails 3.2
|
56
80
|
|
57
|
-
|
81
|
+
## Contributing
|
58
82
|
|
83
|
+
1. Fork it ( https://github.com/kmcphillips/acts_as_permalink/fork )
|
84
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
85
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
86
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
87
|
+
5. Create a new Pull Request
|
metadata
CHANGED
@@ -1,49 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_permalink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Kevin McPhillips
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '3.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rspec
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: sqlite3
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- -
|
45
|
+
- - ">="
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '0'
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
description: Manages permalink columns in active record models. Strips special characters
|
48
56
|
and spaces, creates before validation, assures uniqueness. That kind of thing.
|
49
57
|
email:
|
@@ -52,39 +60,32 @@ executables: []
|
|
52
60
|
extensions: []
|
53
61
|
extra_rdoc_files: []
|
54
62
|
files:
|
55
|
-
- lib/acts_as_permalink.rb
|
56
|
-
- lib/acts_as_permalink/version.rb
|
57
63
|
- MIT-LICENSE
|
58
|
-
- Rakefile
|
59
64
|
- README.markdown
|
65
|
+
- Rakefile
|
66
|
+
- lib/acts_as_permalink.rb
|
67
|
+
- lib/acts_as_permalink/version.rb
|
60
68
|
homepage: http://github.com/kmcphillips/acts_as_permalink
|
61
69
|
licenses: []
|
70
|
+
metadata: {}
|
62
71
|
post_install_message:
|
63
72
|
rdoc_options: []
|
64
73
|
require_paths:
|
65
74
|
- lib
|
66
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
76
|
requirements:
|
69
|
-
- -
|
77
|
+
- - ">="
|
70
78
|
- !ruby/object:Gem::Version
|
71
79
|
version: '0'
|
72
|
-
segments:
|
73
|
-
- 0
|
74
|
-
hash: -473665709
|
75
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
81
|
requirements:
|
78
|
-
- -
|
82
|
+
- - ">="
|
79
83
|
- !ruby/object:Gem::Version
|
80
84
|
version: '0'
|
81
|
-
segments:
|
82
|
-
- 0
|
83
|
-
hash: -473665709
|
84
85
|
requirements: []
|
85
86
|
rubyforge_project:
|
86
|
-
rubygems_version:
|
87
|
+
rubygems_version: 2.2.2
|
87
88
|
signing_key:
|
88
|
-
specification_version:
|
89
|
+
specification_version: 4
|
89
90
|
summary: Automatically manage permalink fields for ActiveRecord models in Rails.
|
90
91
|
test_files: []
|