Skip to content

Instantly share code, notes, and snippets.

@karuna24s
Created October 24, 2016 16:33
Show Gist options
  • Save karuna24s/1bc1fd66b28c5abd995cb92516e35418 to your computer and use it in GitHub Desktop.
Save karuna24s/1bc1fd66b28c5abd995cb92516e35418 to your computer and use it in GitHub Desktop.
class CommentsController < ApplicationController
before_action :set_destination
def create
@comment = current_user.comments.create(comment_params)
@comment.destination = @destination
@comment.save
redirect_to destination_path(@destination)
end
private
def set_destination
@destination = Destination.find(params[:destination_id])
end
def comment_params
params.require(:comment).permit(:content)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment