0

I want my logged in user to be able to create a new "forum". When they fill out the information in the form and click submit it will add 'admin' to their user table.

def create
@forum = Forum.new(forum)

respond_to do |format|
  if @forum.save
    format.html { redirect_to @forum, notice: 'Forum was successfully created.' }
    format.json { render action: 'show', status: :created, location: @forum }
    format.json { current_user.update_attribute :admin, true }
  else
    format.html { render action: 'new' }
    format.json { render json: @forum.errors, status: :unprocessable_entity }
  end
end

end

I thought this would work but when I try it I get

ActiveModel::ForbiddenAttributesError
1
  • Please share the Forum schema and forum method. Commented Feb 28, 2014 at 22:03

1 Answer 1

0

it is happening because of strong_parameter , you have to pass permit in forum method .

Sign up to request clarification or add additional context in comments.

6 Comments

How do I do that? What do I add to the params.require(:forum).permit(:name)
please include your forum defination/method in question.
def set_forum @forum = Forum.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def forum params.require(:forum).permit(:name) end
Is that what you are looking for?
yes, few more things. the error which i believe is occurred because you haven't whilelisted all attributes which will going to change. Please now include output of Forum.new output and puts params .Please put the output in question or some gits instead of pasting here.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.