Last active
February 11, 2016 21:54
-
-
Save megamos/9074ccd165f394415c9a to your computer and use it in GitHub Desktop.
Setting values other then from form on create
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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