Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Update comment from /mentors/applications/:id page
Browse files Browse the repository at this point in the history
  • Loading branch information
stlireri committed May 20, 2018
1 parent a5c955d commit a672757
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/controllers/mentors/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def create
end

def update
comment = mentor_comments.update(params[:id], update_params)
comment = mentor_comments.update(params[:mentor_comment][:commentable_id], update_params)
redirect_to path_for(comment)
end

Expand All @@ -20,7 +20,7 @@ def create_params
end

def update_params
params.require(:mentor_comment).permit(:text)
params.require(:mentor_comment).permit(:id, :text)
end

def path_for(comment)
Expand Down
3 changes: 2 additions & 1 deletion app/views/mentors/applications/_comment.html.slim
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
hr(id="#{dom_id comment}")
= simple_form_for comment, url: mentors_comments_path do |f|
= simple_form_for comment, :url => comment.new_record? ? url_for(action: 'create', controller: 'mentors/comments') :url_for(action: 'update', controller: 'mentors/comments') do |f|
.form-inputs.clearfix
= f.input :commentable_id, as: :hidden, value: comment.commentable_id
= f.input :id, as: :hidden, value: comment.id
= f.input :text, as: :text, label: 'My Comment', input_html: { rows: 5 }, hint: 'This is a place for you to take notes for yourself about this application. Your comment is only visible to yourself as well as the selection committee and you can update and remove it as you like.'
.form-actions
= f.button :submit
2 changes: 1 addition & 1 deletion spec/controllers/mentors/comments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

context 'when comment exists' do
let!(:comment) { Mentor::Comment.create(user: user, commentable_id: 1, text: 'something') }
let(:params) {{ id: comment.id, mentor_comment: { text: 'something else' } }}
let(:params) {{ id: comment.id, mentor_comment: { text: 'something else', commentable_id: comment.id } }}

subject { put :update, params: params }

Expand Down

0 comments on commit a672757

Please sign in to comment.