Class: CommentsController
Instance Method Summary
collapse
#advertise, #cache_action?, #css_help, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index
#get_matching_ui_locale, #get_sorted_langs_from_accept_header, #get_valid_lang_from_accept_header, #set_locale
#login_by_token, #update_last_seen_at
Instance Method Details
#create ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'app/controllers/comments_controller.rb', line 90
def create
= (params[:commentable_type])
= .singularize.constantize.find(params[:commentable_id])
= .new(params[:comment])
. =
.recipient = .owner
.user_id = current_user.id if current_user
.author_ip = request.remote_ip
respond_to do |format|
if (logged_in? || verify_recaptcha()) && .save
.send_notifications
flash.now[:notice] = :comment_was_successfully_created.l
format.html { redirect_to () }
format.js
else
flash.now[:error] = :comment_save_error.l_with_args(:error => .errors.full_messages.to_sentence)
format.html { redirect_to (.tableize, ) }
format.js
end
end
end
|
#delete_selected ⇒ Object
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'app/controllers/comments_controller.rb', line 135
def delete_selected
if request.post?
if params[:delete]
params[:delete].each { |id|
= .find(id)
.spam! if params[:spam] && !configatron.akismet_key.nil?
.destroy if .can_be_deleted_by(current_user)
}
end
flash[:notice] = :comments_deleted.l
redirect_to
end
end
|
#destroy ⇒ Object
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'app/controllers/comments_controller.rb', line 116
def destroy
= .find(params[:id])
if .can_be_deleted_by(current_user) && .destroy
if params[:spam] && !configatron.akismet_key.nil?
.spam!
end
flash.now[:notice] = :the_comment_was_deleted.l
else
flash.now[:error] = :comment_could_not_be_deleted.l
end
respond_to do |format|
format.html { redirect_to users_url }
format.js {
render :inline => flash[:error], :status => 500 if flash[:error]
render :nothing => true if flash[:notice]
}
end
end
|
#edit ⇒ Object
16
17
18
19
20
21
|
# File 'app/controllers/comments_controller.rb', line 16
def edit
= .find(params[:id])
respond_to do |format|
format.js
end
end
|
#index ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'app/controllers/comments_controller.rb', line 32
def index
= (params[:commentable_type])
= .singularize.constantize
= .humanize
= .tableize
if = .find(params[:commentable_id])
unless logged_in? || (.owner && .owner.profile_public?)
flash.now[:error] = :private_user_profile_message.l
redirect_to login_path and return
end
= ..recent.page(params[:page])
@title =
= (, , :format => :rss)
if .any?
= .first
@user = .recipient
@title = .
@back_url = ()
respond_to do |format|
= "#{configatron.community_name}: #{commentable_type_humanized} Comments - #{@title}"
format.html
format. {
(, , ) and return
}
end
else
if .is_a?(User)
@user =
@title = @user.login
@back_url = user_path(@user)
elsif @user = .user
@title = .respond_to?(:title) ? .title : @title
@back_url = url_for([@user, ])
end
respond_to do |format|
format.html
format. {
= "#{configatron.community_name}: #{commentable_type_humanized} Comments - #{@title}"
([], , ) and return
}
end
end
else
flash[:notice] = :no_comments_found.l_with_args(:type => )
redirect_to home_path
end
end
|
#new ⇒ Object
84
85
86
87
|
# File 'app/controllers/comments_controller.rb', line 84
def new
= (params[:commentable_type]).constantize.find(params[:commentable_id])
redirect_to (.class.to_s.tableize, .id)
end
|
#unsubscribe ⇒ Object
150
151
152
153
154
155
156
157
|
# File 'app/controllers/comments_controller.rb', line 150
def unsubscribe
= .find(params[:id])
if .token_for(params[:email]).eql?(params[:token])
.unsubscribe_notifications(params[:email])
flash[:notice] = :comment_unsubscribe_succeeded.l
end
redirect_to ()
end
|
#update ⇒ Object
23
24
25
26
27
28
29
|
# File 'app/controllers/comments_controller.rb', line 23
def update
= .find(params[:id])
.update_attributes(params[:comment])
respond_to do |format|
format.js
end
end
|