Skip to content

Instantly share code, notes, and snippets.

@scottillogical
Last active December 18, 2015 09:18
Show Gist options
  • Save scottillogical/5760020 to your computer and use it in GitHub Desktop.
Save scottillogical/5760020 to your computer and use it in GitHub Desktop.
Rails 4 ActiveModel::ForbiddenAttributesError
class ResourcesController < ApplicationController
def create
@resource = Resource.new(params[:resource])
respond_to do |format|
if @resource.save
format.html { redirect_to @resource.skill, notice: 'Resource was successfully created.' }
else
format.html { render @resource.skill }
end
end
end
private
def resource_params
params.require(:resource).permit(:vote, :name, :skill, :skill_id, :url)
end
end
Started POST "/resources" for 127.0.0.1 at 2013-06-11 15:45:54 -0400
Processing by ResourcesController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"jsdtTmMi+8TPsA+4AkZn45ItIURaeCRVMiMMT4UL0WY=", "resource"=>{"name"=>"test", "url"=>"", "skill_id"=>"2"}, "commit"=>"Create"}
Completed 500 Internal Server Error in 1ms
ActiveModel::ForbiddenAttributesError (ActiveModel::ForbiddenAttributesError):
app/controllers/resources_controller.rb:3:in `create'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment