acts_as_previous_next 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +7 -0
- data/Gemfile +2 -22
- data/README.md +66 -0
- data/acts_as_previous_next.gemspec +7 -4
- data/lib/acts_as_previous_next/version.rb +1 -1
- data/scripts/build_db.sh +6 -0
- metadata +126 -27
- data/Gemfile.lock +0 -141
- data/MIT-LICENSE +0 -20
- data/README.rdoc +0 -50
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,25 +1,5 @@
|
|
1
|
-
source "
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
# Declare your gem's dependencies in acts_as_previous_next.gemspec.
|
4
|
-
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
-
# development dependencies will be added by default to the :development group.
|
6
3
|
gemspec
|
7
4
|
|
8
|
-
|
9
|
-
#gem "jquery-rails"
|
10
|
-
|
11
|
-
# Declare any dependencies that are still in development here instead of in
|
12
|
-
# your gemspec. These might include edge Rails or gems from your path or
|
13
|
-
# Git. Remember to move these dependencies to your gemspec before releasing
|
14
|
-
# your gem to rubygems.org.
|
15
|
-
|
16
|
-
# To use debugger
|
17
|
-
# gem 'ruby-debug19', :require => 'ruby-debug'
|
18
|
-
gem 'rspec-rails', :git => "git://github.com/rspec/rspec-rails.git"
|
19
|
-
gem 'database_cleaner', :git => "git://github.com/asanghi/database_cleaner.git"
|
20
|
-
gem 'cancan'
|
21
|
-
#gem 'factory_girl_rails'
|
22
|
-
#gem 'spork', '0.9.0.rc9'
|
23
|
-
gem 'rb-fsevent'
|
24
|
-
#gem 'guard-rspec'
|
25
|
-
gem 'libnotify'
|
5
|
+
gem "cancan"
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# ActsAsPreviousNext
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/chief/acts_as_previous_next.png?branch=master)](https://travis-ci.org/chief/acts_as_previous_next)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/chief/acts_as_previous_next.png)](https://codeclimate.com/github/chief/acts_as_previous_next)
|
5
|
+
|
6
|
+
## Description
|
7
|
+
|
8
|
+
This `acts_as` extension provides the capability for having previous & next methods
|
9
|
+
for an object. Previous & next are based on a specified column (default is id).
|
10
|
+
|
11
|
+
## Install
|
12
|
+
|
13
|
+
* Rails >= 3
|
14
|
+
|
15
|
+
In your Gemfile
|
16
|
+
|
17
|
+
`gem 'acts_as_previous_next'`
|
18
|
+
|
19
|
+
Currently is tested on ruby 1.9.3 & 2.0.0 and mysql
|
20
|
+
|
21
|
+
## Example
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
class Post < ActiveRecord::Base
|
25
|
+
acts_as_previous_next
|
26
|
+
# acts_as_previous_next column: :id
|
27
|
+
# or
|
28
|
+
# acts_as_previous_next :id
|
29
|
+
end
|
30
|
+
|
31
|
+
post = Post.new
|
32
|
+
post.next # => nil
|
33
|
+
post.save
|
34
|
+
post.next # => post
|
35
|
+
post.previous # => post
|
36
|
+
another_post = Post.new
|
37
|
+
another_post.save
|
38
|
+
another_post.next # => post
|
39
|
+
another_post.previous # => post
|
40
|
+
```
|
41
|
+
|
42
|
+
## Authorization support
|
43
|
+
|
44
|
+
Currently [CanCan](https://github.com/ryanb/cancan) authorization is supported
|
45
|
+
as option (`false` by default). If cancan authorization is enabled then `current_ability`
|
46
|
+
must be passed to `previous` `next` methods. So the previous example with cancan:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
class Post < ActiveRecord::Base
|
50
|
+
acts_as_previous_next with_cancan: true
|
51
|
+
|
52
|
+
belongs_to :user
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
And in your view:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
link_to 'Next', @post.next(current_ability)
|
60
|
+
link_to 'Previous', @post.previous(current_ability)
|
61
|
+
```
|
62
|
+
|
63
|
+
## License
|
64
|
+
|
65
|
+
acts_as_previous_next is released under the [MIT License](http://opensource.org/licenses/MIT)
|
66
|
+
|
@@ -20,12 +20,15 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ['lib']
|
21
21
|
#s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
|
22
22
|
|
23
|
-
s.add_dependency '
|
23
|
+
s.add_dependency 'activesupport', ['>= 3.0.0']
|
24
|
+
s.add_dependency 'activerecord', ['>= 3.0.0']
|
24
25
|
|
25
26
|
s.add_development_dependency 'mysql2'
|
27
|
+
s.add_development_dependency 'rails', ['= 3.2.16']
|
28
|
+
s.add_development_dependency "rspec"
|
29
|
+
s.add_development_dependency "rspec-rails"
|
26
30
|
s.add_development_dependency 'factory_girl_rails'
|
27
|
-
s.add_development_dependency 'spork'
|
28
|
-
|
31
|
+
s.add_development_dependency 'spork'
|
32
|
+
s.add_development_dependency 'database_cleaner'
|
29
33
|
s.add_development_dependency 'guard-rspec'
|
30
|
-
#s.add_development_dependency 'libnotify'
|
31
34
|
end
|
data/scripts/build_db.sh
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_previous_next
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,91 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement:
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: activerecord
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
17
33
|
none: false
|
18
34
|
requirements:
|
19
|
-
- -
|
35
|
+
- - ! '>='
|
20
36
|
- !ruby/object:Gem::Version
|
21
|
-
version: 3.
|
37
|
+
version: 3.0.0
|
22
38
|
type: :runtime
|
23
39
|
prerelease: false
|
24
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.0.0
|
25
46
|
- !ruby/object:Gem::Dependency
|
26
47
|
name: mysql2
|
27
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rails
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 3.2.16
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - '='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.2.16
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec-rails
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
28
97
|
none: false
|
29
98
|
requirements:
|
30
99
|
- - ! '>='
|
@@ -32,10 +101,15 @@ dependencies:
|
|
32
101
|
version: '0'
|
33
102
|
type: :development
|
34
103
|
prerelease: false
|
35
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
36
110
|
- !ruby/object:Gem::Dependency
|
37
111
|
name: factory_girl_rails
|
38
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
39
113
|
none: false
|
40
114
|
requirements:
|
41
115
|
- - ! '>='
|
@@ -43,21 +117,47 @@ dependencies:
|
|
43
117
|
version: '0'
|
44
118
|
type: :development
|
45
119
|
prerelease: false
|
46
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
47
126
|
- !ruby/object:Gem::Dependency
|
48
127
|
name: spork
|
49
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
137
|
none: false
|
51
138
|
requirements:
|
52
|
-
- -
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: database_cleaner
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
53
148
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
149
|
+
version: '0'
|
55
150
|
type: :development
|
56
151
|
prerelease: false
|
57
|
-
version_requirements:
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
58
158
|
- !ruby/object:Gem::Dependency
|
59
159
|
name: guard-rspec
|
60
|
-
requirement:
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
61
161
|
none: false
|
62
162
|
requirements:
|
63
163
|
- - ! '>='
|
@@ -65,7 +165,12 @@ dependencies:
|
|
65
165
|
version: '0'
|
66
166
|
type: :development
|
67
167
|
prerelease: false
|
68
|
-
version_requirements:
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
69
174
|
description: ! "This 'acts_as' extension provides the capability for having previous
|
70
175
|
next methods for object.\n Previous & next are based on a specified column (default
|
71
176
|
is id)."
|
@@ -77,16 +182,16 @@ extra_rdoc_files: []
|
|
77
182
|
files:
|
78
183
|
- .gitignore
|
79
184
|
- .rspec
|
185
|
+
- .travis.yml
|
80
186
|
- Gemfile
|
81
|
-
- Gemfile.lock
|
82
187
|
- Guardfile
|
83
|
-
-
|
84
|
-
- README.rdoc
|
188
|
+
- README.md
|
85
189
|
- Rakefile
|
86
190
|
- acts_as_previous_next.gemspec
|
87
191
|
- lib/acts_as_previous_next.rb
|
88
192
|
- lib/acts_as_previous_next/version.rb
|
89
193
|
- lib/tasks/acts_as_previous_next_tasks.rake
|
194
|
+
- scripts/build_db.sh
|
90
195
|
- spec/dummy/README.rdoc
|
91
196
|
- spec/dummy/Rakefile
|
92
197
|
- spec/dummy/app/assets/javascripts/application.js
|
@@ -145,21 +250,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
250
|
- - ! '>='
|
146
251
|
- !ruby/object:Gem::Version
|
147
252
|
version: '0'
|
148
|
-
segments:
|
149
|
-
- 0
|
150
|
-
hash: -1164763155175909225
|
151
253
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
254
|
none: false
|
153
255
|
requirements:
|
154
256
|
- - ! '>='
|
155
257
|
- !ruby/object:Gem::Version
|
156
258
|
version: '0'
|
157
|
-
segments:
|
158
|
-
- 0
|
159
|
-
hash: -1164763155175909225
|
160
259
|
requirements: []
|
161
260
|
rubyforge_project:
|
162
|
-
rubygems_version: 1.8.
|
261
|
+
rubygems_version: 1.8.23
|
163
262
|
signing_key:
|
164
263
|
specification_version: 3
|
165
264
|
summary: A gem allowing an actire_record model to have previous, next based on a column.
|
data/Gemfile.lock
DELETED
@@ -1,141 +0,0 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git://github.com/asanghi/database_cleaner.git
|
3
|
-
revision: b2d2ce7ff782542b23c2f45e6c0ea9ef0c25c0cd
|
4
|
-
specs:
|
5
|
-
database_cleaner (0.7.0)
|
6
|
-
|
7
|
-
GIT
|
8
|
-
remote: git://github.com/rspec/rspec-rails.git
|
9
|
-
revision: 8ed140d5238fef0cd37e7f58fd8e038ea932146d
|
10
|
-
specs:
|
11
|
-
rspec-rails (2.8.1)
|
12
|
-
actionpack (>= 3.0)
|
13
|
-
activesupport (>= 3.0)
|
14
|
-
railties (>= 3.0)
|
15
|
-
rspec (~> 2.8.0)
|
16
|
-
|
17
|
-
PATH
|
18
|
-
remote: .
|
19
|
-
specs:
|
20
|
-
acts_as_previous_next (0.0.4)
|
21
|
-
rails (~> 3.2.1)
|
22
|
-
|
23
|
-
GEM
|
24
|
-
remote: http://rubygems.org/
|
25
|
-
specs:
|
26
|
-
actionmailer (3.2.1)
|
27
|
-
actionpack (= 3.2.1)
|
28
|
-
mail (~> 2.4.0)
|
29
|
-
actionpack (3.2.1)
|
30
|
-
activemodel (= 3.2.1)
|
31
|
-
activesupport (= 3.2.1)
|
32
|
-
builder (~> 3.0.0)
|
33
|
-
erubis (~> 2.7.0)
|
34
|
-
journey (~> 1.0.1)
|
35
|
-
rack (~> 1.4.0)
|
36
|
-
rack-cache (~> 1.1)
|
37
|
-
rack-test (~> 0.6.1)
|
38
|
-
sprockets (~> 2.1.2)
|
39
|
-
activemodel (3.2.1)
|
40
|
-
activesupport (= 3.2.1)
|
41
|
-
builder (~> 3.0.0)
|
42
|
-
activerecord (3.2.1)
|
43
|
-
activemodel (= 3.2.1)
|
44
|
-
activesupport (= 3.2.1)
|
45
|
-
arel (~> 3.0.0)
|
46
|
-
tzinfo (~> 0.3.29)
|
47
|
-
activeresource (3.2.1)
|
48
|
-
activemodel (= 3.2.1)
|
49
|
-
activesupport (= 3.2.1)
|
50
|
-
activesupport (3.2.1)
|
51
|
-
i18n (~> 0.6)
|
52
|
-
multi_json (~> 1.0)
|
53
|
-
arel (3.0.0)
|
54
|
-
builder (3.0.0)
|
55
|
-
cancan (1.6.7)
|
56
|
-
diff-lcs (1.1.3)
|
57
|
-
erubis (2.7.0)
|
58
|
-
factory_girl (2.3.2)
|
59
|
-
activesupport
|
60
|
-
factory_girl_rails (1.4.0)
|
61
|
-
factory_girl (~> 2.3.0)
|
62
|
-
railties (>= 3.0.0)
|
63
|
-
ffi (1.0.11)
|
64
|
-
guard (0.10.0)
|
65
|
-
ffi (>= 0.5.0)
|
66
|
-
thor (~> 0.14.6)
|
67
|
-
guard-rspec (0.6.0)
|
68
|
-
guard (>= 0.10.0)
|
69
|
-
hike (1.2.1)
|
70
|
-
i18n (0.6.0)
|
71
|
-
journey (1.0.1)
|
72
|
-
json (1.6.5)
|
73
|
-
libnotify (0.7.1)
|
74
|
-
mail (2.4.1)
|
75
|
-
i18n (>= 0.4.0)
|
76
|
-
mime-types (~> 1.16)
|
77
|
-
treetop (~> 1.4.8)
|
78
|
-
mime-types (1.17.2)
|
79
|
-
multi_json (1.0.4)
|
80
|
-
mysql2 (0.3.11)
|
81
|
-
polyglot (0.3.3)
|
82
|
-
rack (1.4.1)
|
83
|
-
rack-cache (1.1)
|
84
|
-
rack (>= 0.4)
|
85
|
-
rack-ssl (1.3.2)
|
86
|
-
rack
|
87
|
-
rack-test (0.6.1)
|
88
|
-
rack (>= 1.0)
|
89
|
-
rails (3.2.1)
|
90
|
-
actionmailer (= 3.2.1)
|
91
|
-
actionpack (= 3.2.1)
|
92
|
-
activerecord (= 3.2.1)
|
93
|
-
activeresource (= 3.2.1)
|
94
|
-
activesupport (= 3.2.1)
|
95
|
-
bundler (~> 1.0)
|
96
|
-
railties (= 3.2.1)
|
97
|
-
railties (3.2.1)
|
98
|
-
actionpack (= 3.2.1)
|
99
|
-
activesupport (= 3.2.1)
|
100
|
-
rack-ssl (~> 1.3.2)
|
101
|
-
rake (>= 0.8.7)
|
102
|
-
rdoc (~> 3.4)
|
103
|
-
thor (~> 0.14.6)
|
104
|
-
rake (0.9.2.2)
|
105
|
-
rb-fsevent (0.4.3.1)
|
106
|
-
rdoc (3.12)
|
107
|
-
json (~> 1.4)
|
108
|
-
rspec (2.8.0)
|
109
|
-
rspec-core (~> 2.8.0)
|
110
|
-
rspec-expectations (~> 2.8.0)
|
111
|
-
rspec-mocks (~> 2.8.0)
|
112
|
-
rspec-core (2.8.0)
|
113
|
-
rspec-expectations (2.8.0)
|
114
|
-
diff-lcs (~> 1.1.2)
|
115
|
-
rspec-mocks (2.8.0)
|
116
|
-
spork (0.9.0.rc9)
|
117
|
-
sprockets (2.1.2)
|
118
|
-
hike (~> 1.2)
|
119
|
-
rack (~> 1.0)
|
120
|
-
tilt (~> 1.1, != 1.3.0)
|
121
|
-
thor (0.14.6)
|
122
|
-
tilt (1.3.3)
|
123
|
-
treetop (1.4.10)
|
124
|
-
polyglot
|
125
|
-
polyglot (>= 0.3.1)
|
126
|
-
tzinfo (0.3.31)
|
127
|
-
|
128
|
-
PLATFORMS
|
129
|
-
ruby
|
130
|
-
|
131
|
-
DEPENDENCIES
|
132
|
-
acts_as_previous_next!
|
133
|
-
cancan
|
134
|
-
database_cleaner!
|
135
|
-
factory_girl_rails
|
136
|
-
guard-rspec
|
137
|
-
libnotify
|
138
|
-
mysql2
|
139
|
-
rb-fsevent
|
140
|
-
rspec-rails!
|
141
|
-
spork (= 0.9.0.rc9)
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2012 YOURNAME
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
= ActsAsPreviousNext
|
2
|
-
|
3
|
-
== Description
|
4
|
-
|
5
|
-
This 'acts_as' extension provides the capability for having previous & next methods for an object.
|
6
|
-
Previous & next are based on a specified column (default is id).
|
7
|
-
|
8
|
-
== Install
|
9
|
-
|
10
|
-
In your Gemfile
|
11
|
-
|
12
|
-
gem 'acts_as_previous_next'
|
13
|
-
|
14
|
-
Currently is tested on rails3.2.0.rc2, ruby 1.9.3 and mysql
|
15
|
-
|
16
|
-
== Example
|
17
|
-
|
18
|
-
class Post < ActiveRecord::Base
|
19
|
-
acts_as_previous_next
|
20
|
-
# acts_as_previous_next column: :id
|
21
|
-
# or
|
22
|
-
# acts_as_previous_next :id
|
23
|
-
end
|
24
|
-
|
25
|
-
post = Post.new
|
26
|
-
post.next # => nil
|
27
|
-
post.save
|
28
|
-
post.next # => post
|
29
|
-
post.previous # => post
|
30
|
-
another_post = Post.new
|
31
|
-
another_post.save
|
32
|
-
another_post.next # => post
|
33
|
-
another_post.previous # => post
|
34
|
-
|
35
|
-
Currently CanCan authorization is supported as option (+false+ by default). If cancan authorization is
|
36
|
-
enabled then +current_ability+ must be passed to next, previous methods. So the previous example
|
37
|
-
with cancan will be:
|
38
|
-
|
39
|
-
class Post < ActiveRecord::Base
|
40
|
-
acts_as_previous_next with_cancan: true
|
41
|
-
|
42
|
-
belongs_to :user
|
43
|
-
end
|
44
|
-
|
45
|
-
And in your view:
|
46
|
-
|
47
|
-
link_to 'Next', @post.next(current_ability)
|
48
|
-
link_to 'Previous', @post.previous(current_ability)
|
49
|
-
|
50
|
-
|