Question

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
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top