Skip to content

Instantly share code, notes, and snippets.

@megamos
Last active February 11, 2016 21:54
Show Gist options
  • Save megamos/9074ccd165f394415c9a to your computer and use it in GitHub Desktop.
Save megamos/9074ccd165f394415c9a to your computer and use it in GitHub Desktop.
Setting values other then from form on create
def create
@feedback = Feedback.new(feedback_params)
respond_to do |format|
if @feedback.save
if current_user
@feedback.created_by = current_user.id
format.html { redirect_to user_path(current_user), notice: "Tack för din feedback!"}
end
format.html { redirect_to root_path, notice: "Tack för din feedback!"}
else
format.html { render :new }
end
end
end
def destroy
@feedback.destroy
redirect_to root_path
end
private
def feedback_params
params.require(:feedback).permit(:subject,:body)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment