merit 1.7.1 → 1.8.0
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 +4 -4
- data/CHANGELOG.md +6 -1
- data/Gemfile +7 -0
- data/README.md +31 -4
- data/app/models/merit/action.rb +2 -3
- data/app/models/merit/badge.rb +2 -2
- data/lib/generators/active_record/install_generator.rb +1 -1
- data/lib/generators/active_record/merit_generator.rb +2 -2
- data/lib/generators/active_record/remove_generator.rb +2 -2
- data/lib/generators/active_record/templates/create_badges_sashes.rb +1 -1
- data/lib/generators/active_record/templates/create_merit_actions.rb +3 -3
- data/lib/generators/active_record/templates/create_scores_and_points.rb +2 -2
- data/lib/generators/active_record/templates/remove_merit_tables.rb +1 -1
- data/lib/generators/merit/install_generator.rb +1 -1
- data/lib/generators/merit/merit_generator.rb +2 -3
- data/lib/generators/merit/remove_generator.rb +3 -3
- data/lib/generators/merit/templates/merit.rb +10 -4
- data/lib/merit.rb +43 -15
- data/lib/merit/base_target_finder.rb +1 -3
- data/lib/merit/judge.rb +26 -6
- data/lib/merit/model_additions.rb +10 -17
- data/lib/merit/models/active_record/merit/action.rb +1 -1
- data/lib/merit/models/active_record/merit/activity_log.rb +1 -0
- data/lib/merit/models/active_record/merit/badges_sash.rb +6 -10
- data/lib/merit/models/active_record/merit/sash.rb +2 -38
- data/lib/merit/models/active_record/merit/score.rb +6 -5
- data/lib/merit/models/base/merit/badges_sash.rb +15 -0
- data/lib/merit/models/base/merit/sash.rb +42 -0
- data/lib/merit/models/mongoid/merit/action.rb +8 -6
- data/lib/merit/models/mongoid/merit/activity_log.rb +11 -0
- data/lib/merit/models/mongoid/merit/badges_sash.rb +19 -0
- data/lib/merit/models/mongoid/merit/sash.rb +28 -0
- data/lib/merit/models/mongoid/merit/score.rb +41 -0
- data/lib/merit/reputation_change_observer.rb +11 -0
- data/lib/merit/rule.rb +1 -1
- data/lib/merit/rules_matcher.rb +0 -2
- data/lib/merit/rules_rank_methods.rb +1 -1
- data/lib/merit/target_finder.rb +1 -2
- data/merit.gemspec +2 -1
- data/test/dummy/app/models/comment.rb +16 -1
- data/test/dummy/app/models/dummy_observer.rb +3 -0
- data/test/dummy/app/models/user.rb +14 -1
- data/test/dummy/config/initializers/merit.rb +3 -4
- data/test/dummy/config/mongoid.yml +13 -0
- data/test/integration/navigation_test.rb +19 -2
- data/test/unit/merit_unit_test.rb +1 -1
- metadata +25 -56
- data/lib/merit/models/mongoid/sash.rb +0 -14
- data/lib/merit/observer.rb +0 -13
- data/test/dummy-mongoid/Rakefile +0 -7
- data/test/dummy-mongoid/app/controllers/application_controller.rb +0 -7
- data/test/dummy-mongoid/app/controllers/comments_controller.rb +0 -90
- data/test/dummy-mongoid/app/controllers/registrations_controller.rb +0 -15
- data/test/dummy-mongoid/app/controllers/users_controller.rb +0 -67
- data/test/dummy-mongoid/app/helpers/application_helper.rb +0 -2
- data/test/dummy-mongoid/app/models/comment.rb +0 -13
- data/test/dummy-mongoid/app/models/merit/badge_rules.rb +0 -49
- data/test/dummy-mongoid/app/models/merit/point_rules.rb +0 -20
- data/test/dummy-mongoid/app/models/merit/rank_rules.rb +0 -24
- data/test/dummy-mongoid/app/models/user.rb +0 -25
- data/test/dummy-mongoid/app/views/comments/_form.html.erb +0 -29
- data/test/dummy-mongoid/app/views/comments/edit.html.erb +0 -6
- data/test/dummy-mongoid/app/views/comments/index.html.erb +0 -35
- data/test/dummy-mongoid/app/views/comments/new.html.erb +0 -5
- data/test/dummy-mongoid/app/views/comments/show.html.erb +0 -23
- data/test/dummy-mongoid/app/views/layouts/application.html.erb +0 -24
- data/test/dummy-mongoid/app/views/users/_form.html.erb +0 -22
- data/test/dummy-mongoid/app/views/users/edit.html.erb +0 -6
- data/test/dummy-mongoid/app/views/users/index.html.erb +0 -26
- data/test/dummy-mongoid/app/views/users/new.html.erb +0 -5
- data/test/dummy-mongoid/app/views/users/show.html.erb +0 -18
- data/test/dummy-mongoid/config.ru +0 -4
- data/test/dummy-mongoid/config/application.rb +0 -22
- data/test/dummy-mongoid/config/boot.rb +0 -10
- data/test/dummy-mongoid/config/environment.rb +0 -5
- data/test/dummy-mongoid/config/environments/development.rb +0 -25
- data/test/dummy-mongoid/config/environments/production.rb +0 -49
- data/test/dummy-mongoid/config/environments/test.rb +0 -35
- data/test/dummy-mongoid/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy-mongoid/config/initializers/inflections.rb +0 -10
- data/test/dummy-mongoid/config/initializers/merit.rb +0 -37
- data/test/dummy-mongoid/config/initializers/mime_types.rb +0 -5
- data/test/dummy-mongoid/config/initializers/secret_token.rb +0 -7
- data/test/dummy-mongoid/config/initializers/session_store.rb +0 -8
- data/test/dummy-mongoid/config/locales/en.yml +0 -5
- data/test/dummy-mongoid/config/mongoid.yml +0 -14
- data/test/dummy-mongoid/config/routes.rb +0 -9
- data/test/dummy-mongoid/db/seeds.rb +0 -17
- data/test/dummy-mongoid/public/404.html +0 -26
- data/test/dummy-mongoid/public/422.html +0 -26
- data/test/dummy-mongoid/public/500.html +0 -26
- data/test/dummy-mongoid/public/favicon.ico +0 -0
- data/test/dummy-mongoid/public/javascripts/application.js +0 -2
- data/test/dummy-mongoid/public/javascripts/controls.js +0 -965
- data/test/dummy-mongoid/public/javascripts/dragdrop.js +0 -974
- data/test/dummy-mongoid/public/javascripts/effects.js +0 -1123
- data/test/dummy-mongoid/public/javascripts/prototype.js +0 -6001
- data/test/dummy-mongoid/public/javascripts/rails.js +0 -191
- data/test/dummy-mongoid/public/stylesheets/.gitkeep +0 -0
- data/test/dummy-mongoid/public/stylesheets/scaffold.css +0 -56
- data/test/dummy-mongoid/script/rails +0 -6
@@ -1,4 +1,19 @@
|
|
1
|
-
|
1
|
+
case Merit.orm
|
2
|
+
when :active_record
|
3
|
+
class Comment < ActiveRecord::Base
|
4
|
+
end
|
5
|
+
when :mongoid
|
6
|
+
class Comment
|
7
|
+
include Mongoid::Document
|
8
|
+
include Mongoid::Timestamps
|
9
|
+
|
10
|
+
field :name, :type => String
|
11
|
+
field :comment, :type => String
|
12
|
+
field :votes, :type => Integer
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Comment
|
2
17
|
has_merit
|
3
18
|
|
4
19
|
belongs_to :user
|
@@ -1,4 +1,17 @@
|
|
1
|
-
|
1
|
+
case Merit.orm
|
2
|
+
when :active_record
|
3
|
+
class User < ActiveRecord::Base
|
4
|
+
end
|
5
|
+
when :mongoid
|
6
|
+
class User
|
7
|
+
include Mongoid::Document
|
8
|
+
include Mongoid::Timestamps
|
9
|
+
|
10
|
+
field :name, :type => String
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class User
|
2
15
|
has_merit
|
3
16
|
|
4
17
|
has_many :comments
|
@@ -1,10 +1,9 @@
|
|
1
1
|
# Use this hook to configure merit parameters
|
2
2
|
Merit.setup do |config|
|
3
|
-
#
|
4
|
-
|
3
|
+
# Add application observers to get notifications any time merit changes reputation.
|
4
|
+
config.add_observer 'DummyObserver'
|
5
5
|
|
6
|
-
|
7
|
-
# config.orm = :active_record
|
6
|
+
config.orm = ENV['ORM'].try(:to_sym)
|
8
7
|
end
|
9
8
|
|
10
9
|
# Create application badges (uses https://github.com/norman/ambry)
|
@@ -1,7 +1,12 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class NavigationTest < ActiveSupport::IntegrationCase
|
4
|
+
def tear_down
|
5
|
+
DummyObserver.unstub(:update)
|
6
|
+
end
|
7
|
+
|
4
8
|
test 'user sign up should grant badge to itself' do
|
9
|
+
DummyObserver.any_instance.expects(:update).times 1
|
5
10
|
visit '/users/new'
|
6
11
|
fill_in 'Name', with: 'Jack'
|
7
12
|
assert_difference('Merit::ActivityLog.count') do
|
@@ -13,6 +18,8 @@ class NavigationTest < ActiveSupport::IntegrationCase
|
|
13
18
|
end
|
14
19
|
|
15
20
|
test 'User#add_badge should add one badge, #rm_badge should delete one' do
|
21
|
+
DummyObserver.any_instance.expects(:update).times 0
|
22
|
+
|
16
23
|
user = User.create(name: 'test-user')
|
17
24
|
assert_equal [], user.badges
|
18
25
|
|
@@ -27,6 +34,7 @@ class NavigationTest < ActiveSupport::IntegrationCase
|
|
27
34
|
end
|
28
35
|
|
29
36
|
test 'Remove inexistent badge should do nothing' do
|
37
|
+
DummyObserver.any_instance.expects(:update).times 0
|
30
38
|
user = User.create(name: 'test-user')
|
31
39
|
assert_equal [], user.badges
|
32
40
|
user.rm_badge 1
|
@@ -34,6 +42,7 @@ class NavigationTest < ActiveSupport::IntegrationCase
|
|
34
42
|
end
|
35
43
|
|
36
44
|
test 'users#index should grant badge multiple times' do
|
45
|
+
DummyObserver.any_instance.expects(:update).times 14
|
37
46
|
user = User.create(name: 'test-user')
|
38
47
|
|
39
48
|
# Multiple rule
|
@@ -58,6 +67,7 @@ class NavigationTest < ActiveSupport::IntegrationCase
|
|
58
67
|
end
|
59
68
|
|
60
69
|
test 'user workflow should grant some badges at some times' do
|
70
|
+
DummyObserver.any_instance.expects(:update).at_least_once
|
61
71
|
# Commented 9 times, no badges yet
|
62
72
|
user = User.create(name: 'test-user')
|
63
73
|
# Create needed friend user object
|
@@ -124,14 +134,18 @@ class NavigationTest < ActiveSupport::IntegrationCase
|
|
124
134
|
assert_difference('Merit::ActivityLog.count', 2) do
|
125
135
|
click_button('Update User')
|
126
136
|
end
|
127
|
-
|
128
|
-
|
137
|
+
|
138
|
+
# Check created Merit::ActivityLogs
|
139
|
+
assert_equal 'granted commenter badge', Merit::ActivityLog.all[0].description
|
140
|
+
assert_equal 'granted 20 points', Merit::ActivityLog.all[-1].description
|
141
|
+
assert_equal 'removed autobiographer badge', Merit::ActivityLog.all[-2].description
|
129
142
|
|
130
143
|
user = User.where(name: 'abc').first
|
131
144
|
assert !user.badges.include?(autobiographer_badge), "User badges: #{user.badges.collect(&:name).inspect} should remove autobiographer badge."
|
132
145
|
end
|
133
146
|
|
134
147
|
test 'user workflow should add up points at some times' do
|
148
|
+
DummyObserver.any_instance.expects(:update).at_least_once
|
135
149
|
User.delete_all
|
136
150
|
user = User.create(name: 'test-user')
|
137
151
|
assert_equal 0, user.points, 'User should start with 0 points'
|
@@ -184,6 +198,7 @@ class NavigationTest < ActiveSupport::IntegrationCase
|
|
184
198
|
end
|
185
199
|
|
186
200
|
test 'user workflow should grant levels at some times' do
|
201
|
+
DummyObserver.any_instance.expects(:update).at_least_once
|
187
202
|
user = User.create(name: 'test-user')
|
188
203
|
assert user.badges.empty?
|
189
204
|
|
@@ -220,6 +235,7 @@ class NavigationTest < ActiveSupport::IntegrationCase
|
|
220
235
|
end
|
221
236
|
|
222
237
|
test 'assigning points to a group of records' do
|
238
|
+
DummyObserver.any_instance.expects(:update).times 4
|
223
239
|
commenter = User.create(name: 'commenter')
|
224
240
|
comment_1 = commenter.comments.create(name: 'comment_1', comment: 'a')
|
225
241
|
comment_2 = commenter.comments.create(name: 'comment_2', comment: 'b')
|
@@ -237,6 +253,7 @@ class NavigationTest < ActiveSupport::IntegrationCase
|
|
237
253
|
end
|
238
254
|
|
239
255
|
test 'api/comments#show should grant 1 point to user' do
|
256
|
+
DummyObserver.any_instance.expects(:update).times 1
|
240
257
|
user = User.create(name: 'test-user')
|
241
258
|
assert_equal 0, user.points
|
242
259
|
comment = user.comments.create!(name: 'test-comment', comment: 'comment body')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tute Costa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ambry
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: minitest-rails
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,9 +152,14 @@ files:
|
|
138
152
|
- lib/merit/models/active_record/merit/badges_sash.rb
|
139
153
|
- lib/merit/models/active_record/merit/sash.rb
|
140
154
|
- lib/merit/models/active_record/merit/score.rb
|
155
|
+
- lib/merit/models/base/merit/badges_sash.rb
|
156
|
+
- lib/merit/models/base/merit/sash.rb
|
141
157
|
- lib/merit/models/mongoid/merit/action.rb
|
142
|
-
- lib/merit/models/mongoid/
|
143
|
-
- lib/merit/
|
158
|
+
- lib/merit/models/mongoid/merit/activity_log.rb
|
159
|
+
- lib/merit/models/mongoid/merit/badges_sash.rb
|
160
|
+
- lib/merit/models/mongoid/merit/sash.rb
|
161
|
+
- lib/merit/models/mongoid/merit/score.rb
|
162
|
+
- lib/merit/reputation_change_observer.rb
|
144
163
|
- lib/merit/rule.rb
|
145
164
|
- lib/merit/rules_badge_methods.rb
|
146
165
|
- lib/merit/rules_matcher.rb
|
@@ -149,58 +168,6 @@ files:
|
|
149
168
|
- lib/merit/sash_finder.rb
|
150
169
|
- lib/merit/target_finder.rb
|
151
170
|
- merit.gemspec
|
152
|
-
- test/dummy-mongoid/Rakefile
|
153
|
-
- test/dummy-mongoid/app/controllers/application_controller.rb
|
154
|
-
- test/dummy-mongoid/app/controllers/comments_controller.rb
|
155
|
-
- test/dummy-mongoid/app/controllers/registrations_controller.rb
|
156
|
-
- test/dummy-mongoid/app/controllers/users_controller.rb
|
157
|
-
- test/dummy-mongoid/app/helpers/application_helper.rb
|
158
|
-
- test/dummy-mongoid/app/models/comment.rb
|
159
|
-
- test/dummy-mongoid/app/models/merit/badge_rules.rb
|
160
|
-
- test/dummy-mongoid/app/models/merit/point_rules.rb
|
161
|
-
- test/dummy-mongoid/app/models/merit/rank_rules.rb
|
162
|
-
- test/dummy-mongoid/app/models/user.rb
|
163
|
-
- test/dummy-mongoid/app/views/comments/_form.html.erb
|
164
|
-
- test/dummy-mongoid/app/views/comments/edit.html.erb
|
165
|
-
- test/dummy-mongoid/app/views/comments/index.html.erb
|
166
|
-
- test/dummy-mongoid/app/views/comments/new.html.erb
|
167
|
-
- test/dummy-mongoid/app/views/comments/show.html.erb
|
168
|
-
- test/dummy-mongoid/app/views/layouts/application.html.erb
|
169
|
-
- test/dummy-mongoid/app/views/users/_form.html.erb
|
170
|
-
- test/dummy-mongoid/app/views/users/edit.html.erb
|
171
|
-
- test/dummy-mongoid/app/views/users/index.html.erb
|
172
|
-
- test/dummy-mongoid/app/views/users/new.html.erb
|
173
|
-
- test/dummy-mongoid/app/views/users/show.html.erb
|
174
|
-
- test/dummy-mongoid/config.ru
|
175
|
-
- test/dummy-mongoid/config/application.rb
|
176
|
-
- test/dummy-mongoid/config/boot.rb
|
177
|
-
- test/dummy-mongoid/config/environment.rb
|
178
|
-
- test/dummy-mongoid/config/environments/development.rb
|
179
|
-
- test/dummy-mongoid/config/environments/production.rb
|
180
|
-
- test/dummy-mongoid/config/environments/test.rb
|
181
|
-
- test/dummy-mongoid/config/initializers/backtrace_silencers.rb
|
182
|
-
- test/dummy-mongoid/config/initializers/inflections.rb
|
183
|
-
- test/dummy-mongoid/config/initializers/merit.rb
|
184
|
-
- test/dummy-mongoid/config/initializers/mime_types.rb
|
185
|
-
- test/dummy-mongoid/config/initializers/secret_token.rb
|
186
|
-
- test/dummy-mongoid/config/initializers/session_store.rb
|
187
|
-
- test/dummy-mongoid/config/locales/en.yml
|
188
|
-
- test/dummy-mongoid/config/mongoid.yml
|
189
|
-
- test/dummy-mongoid/config/routes.rb
|
190
|
-
- test/dummy-mongoid/db/seeds.rb
|
191
|
-
- test/dummy-mongoid/public/404.html
|
192
|
-
- test/dummy-mongoid/public/422.html
|
193
|
-
- test/dummy-mongoid/public/500.html
|
194
|
-
- test/dummy-mongoid/public/favicon.ico
|
195
|
-
- test/dummy-mongoid/public/javascripts/application.js
|
196
|
-
- test/dummy-mongoid/public/javascripts/controls.js
|
197
|
-
- test/dummy-mongoid/public/javascripts/dragdrop.js
|
198
|
-
- test/dummy-mongoid/public/javascripts/effects.js
|
199
|
-
- test/dummy-mongoid/public/javascripts/prototype.js
|
200
|
-
- test/dummy-mongoid/public/javascripts/rails.js
|
201
|
-
- test/dummy-mongoid/public/stylesheets/.gitkeep
|
202
|
-
- test/dummy-mongoid/public/stylesheets/scaffold.css
|
203
|
-
- test/dummy-mongoid/script/rails
|
204
171
|
- test/dummy/Rakefile
|
205
172
|
- test/dummy/app/controllers/admin/users_controller.rb
|
206
173
|
- test/dummy/app/controllers/api/comments_controller.rb
|
@@ -211,6 +178,7 @@ files:
|
|
211
178
|
- test/dummy/app/controllers/users_controller.rb
|
212
179
|
- test/dummy/app/helpers/application_helper.rb
|
213
180
|
- test/dummy/app/models/comment.rb
|
181
|
+
- test/dummy/app/models/dummy_observer.rb
|
214
182
|
- test/dummy/app/models/merit/badge_rules.rb
|
215
183
|
- test/dummy/app/models/merit/point_rules.rb
|
216
184
|
- test/dummy/app/models/merit/rank_rules.rb
|
@@ -242,6 +210,7 @@ files:
|
|
242
210
|
- test/dummy/config/initializers/secret_token.rb
|
243
211
|
- test/dummy/config/initializers/session_store.rb
|
244
212
|
- test/dummy/config/locales/en.yml
|
213
|
+
- test/dummy/config/mongoid.yml
|
245
214
|
- test/dummy/config/routes.rb
|
246
215
|
- test/dummy/db/migrate/20110421191249_create_users.rb
|
247
216
|
- test/dummy/db/migrate/20110421191250_create_comments.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class Sash
|
2
|
-
include Mongoid::Document
|
3
|
-
include Mongoid::Timestamps
|
4
|
-
|
5
|
-
field :badge_ids, type: Array, default: []
|
6
|
-
|
7
|
-
def add_badge(badge_id)
|
8
|
-
self.push(:badge_ids, badge_id)
|
9
|
-
end
|
10
|
-
|
11
|
-
def rm_badge(badge_id)
|
12
|
-
self.pull(:badge_ids, badge_id)
|
13
|
-
end
|
14
|
-
end
|
data/lib/merit/observer.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module Merit
|
2
|
-
# TODO: Observer is a misleading name, there's no way to register other
|
3
|
-
# observers yet
|
4
|
-
module Observer
|
5
|
-
def notify_observers(action_id, related_change, description = '')
|
6
|
-
ActivityLog.create(
|
7
|
-
action_id: action_id,
|
8
|
-
related_change: related_change,
|
9
|
-
description: description
|
10
|
-
)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/test/dummy-mongoid/Rakefile
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
-
|
4
|
-
require File.expand_path('../config/application', __FILE__)
|
5
|
-
require 'rake'
|
6
|
-
|
7
|
-
DummyMongoid::Application.load_tasks
|
@@ -1,90 +0,0 @@
|
|
1
|
-
class CommentsController < ApplicationController
|
2
|
-
# GET /comments
|
3
|
-
# GET /comments.xml
|
4
|
-
def index
|
5
|
-
@comments = Comment.all
|
6
|
-
|
7
|
-
respond_to do |format|
|
8
|
-
format.html # index.html.erb
|
9
|
-
format.xml { render :xml => @comments }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
# GET /comments/1
|
14
|
-
# GET /comments/1.xml
|
15
|
-
def show
|
16
|
-
@comment = Comment.find(params[:id])
|
17
|
-
|
18
|
-
respond_to do |format|
|
19
|
-
format.html # show.html.erb
|
20
|
-
format.xml { render :xml => @comment }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# GET /comments/new
|
25
|
-
# GET /comments/new.xml
|
26
|
-
def new
|
27
|
-
@comment = Comment.new
|
28
|
-
|
29
|
-
respond_to do |format|
|
30
|
-
format.html # new.html.erb
|
31
|
-
format.xml { render :xml => @comment }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# GET /comments/1/edit
|
36
|
-
def edit
|
37
|
-
@comment = Comment.find(params[:id])
|
38
|
-
end
|
39
|
-
|
40
|
-
def vote
|
41
|
-
@comment = Comment.find(params[:id])
|
42
|
-
@comment.votes += params[:value].to_i
|
43
|
-
@comment.save
|
44
|
-
redirect_to(comments_url, :notice => 'Vote added!')
|
45
|
-
end
|
46
|
-
|
47
|
-
# POST /comments
|
48
|
-
# POST /comments.xml
|
49
|
-
def create
|
50
|
-
@comment = Comment.new(params[:comment])
|
51
|
-
|
52
|
-
respond_to do |format|
|
53
|
-
if @comment.save
|
54
|
-
format.html { redirect_to(@comment, :notice => 'Comment was successfully created.') }
|
55
|
-
format.xml { render :xml => @comment, :status => :created, :location => @comment }
|
56
|
-
else
|
57
|
-
format.html { render "new" }
|
58
|
-
format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
# PUT /comments/1
|
64
|
-
# PUT /comments/1.xml
|
65
|
-
def update
|
66
|
-
@comment = Comment.find(params[:id])
|
67
|
-
|
68
|
-
respond_to do |format|
|
69
|
-
if @comment.update_attributes(params[:comment])
|
70
|
-
format.html { redirect_to(@comment, :notice => 'Comment was successfully updated.') }
|
71
|
-
format.xml { head :ok }
|
72
|
-
else
|
73
|
-
format.html { render "edit" }
|
74
|
-
format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# DELETE /comments/1
|
80
|
-
# DELETE /comments/1.xml
|
81
|
-
def destroy
|
82
|
-
@comment = Comment.find(params[:id])
|
83
|
-
@comment.destroy
|
84
|
-
|
85
|
-
respond_to do |format|
|
86
|
-
format.html { redirect_to(comments_url) }
|
87
|
-
format.xml { head :ok }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class RegistrationsController < ApplicationController
|
2
|
-
def update
|
3
|
-
@user = User.find(params[:id])
|
4
|
-
|
5
|
-
respond_to do |format|
|
6
|
-
if @user.update_attributes(params[:user])
|
7
|
-
format.html { redirect_to(@user, :notice => 'User was successfully updated.') }
|
8
|
-
format.xml { head :ok }
|
9
|
-
else
|
10
|
-
format.html { render "edit" }
|
11
|
-
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|