rewrite comments form, use strong parameters with comments
This commit is contained in:
parent
3ad009658d
commit
3f882957cf
3 changed files with 10 additions and 7 deletions
|
|
@ -94,7 +94,9 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def comment
|
def comment
|
||||||
comment = Comment.build_from(@event, current_user.id, comment_params)
|
comment = Comment.new(comment_params)
|
||||||
|
comment.commentable = @event
|
||||||
|
comment.user_id = current_user.id
|
||||||
comment.save!
|
comment.save!
|
||||||
if !params[:parent].nil?
|
if !params[:parent].nil?
|
||||||
comment.move_to_child_of(params[:parent])
|
comment.move_to_child_of(params[:parent])
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@
|
||||||
%div
|
%div
|
||||||
%a.pull-right.comment-reply-link{href: "#"} Reply
|
%a.pull-right.comment-reply-link{href: "#"} Reply
|
||||||
.comment-reply
|
.comment-reply
|
||||||
= form_tag "#{comment_admin_conference_program_event_path(@conference.short_title, comment.commentable_id)}", method: :post do
|
= semantic_form_for :comment, url: "#{comment_admin_conference_program_event_path(@conference.short_title, comment.commentable_id)}", method: :post do |f|
|
||||||
|
= f.input :body
|
||||||
%input{name: "parent", type: "hidden", value: "#{comment.id}"}
|
%input{name: "parent", type: "hidden", value: "#{comment.id}"}
|
||||||
%input{name: "authenticity_token", type: "hidden", value: "#{form_authenticity_token}"}
|
%input{name: "authenticity_token", type: "hidden", value: "#{form_authenticity_token}"}
|
||||||
%textarea{name: "comment"}
|
|
||||||
%button.btn.btn-primary.pull-right{name: "button", type: "submit"} Add Reply
|
%button.btn.btn-primary.pull-right{name: "button", type: "submit"} Add Reply
|
||||||
- comment.children.each do |child|
|
- comment.children.each do |child|
|
||||||
= render "nested_comments", comment: child, padding: 50
|
= render "nested_comments", comment: child, padding: 50
|
||||||
|
|
|
||||||
|
|
@ -147,10 +147,11 @@
|
||||||
%ul.media
|
%ul.media
|
||||||
%div
|
%div
|
||||||
.row-fluid
|
.row-fluid
|
||||||
= form_tag(comment_admin_conference_program_event_path(@conference.short_title, @event.id), method: :post) do
|
= semantic_form_for :comment, url: comment_admin_conference_program_event_path(@conference.short_title, @event.id), method: :post do |f|
|
||||||
= text_area_tag(:comment, '')
|
= f.input :body
|
||||||
= submit_tag 'Add Comment', class: 'btn btn-primary pull-right'
|
= f.submit 'Add Comment', class: 'btn btn-primary pull-right'
|
||||||
|
%br
|
||||||
%br
|
%br
|
||||||
- @comments.each do |comment|
|
- @comments.each do |comment|
|
||||||
%div
|
%div
|
||||||
= render "nested_comments", comment: comment, padding: 0
|
= render partial: 'nested_comments', locals: { comment: comment, padding: 0}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue