Skip to content

Instantly share code, notes, and snippets.

Created March 13, 2015 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/b25123b9a029968e904b to your computer and use it in GitHub Desktop.
Save anonymous/b25123b9a029968e904b to your computer and use it in GitHub Desktop.
<%= f.fields_for :incomes do |income| %>
<%= income.label :name %>
<%= income.text_field :name %>
<%= income.label :amount %>
<%= income.text_field :amount %>
<% end %>
ActionController::UnpermittedParameters in ProjectionsController#update
found unpermitted parameters: incomes
Parameters:
{"utf8"=>"✓",
"_method"=>"patch",
"authenticity_token"=>"XwA325J64foUZ6I33rNe2Ec4pRqAfHxxW711CBz/jws=",
"projection"=>{"name"=>"help",
"incomes"=>{"name"=>"adfaf",
"amount"=>"323"}},
"commit"=>"Update Projection",
"id"=>"6"}
class Income < ActiveRecord::Base
has_many :income_projections
has_many :projections, :through => :income_projections
accepts_nested_attributes_for :income_projections
end
income_projection.rb
class IncomeProjection < ActiveRecord::Base
belongs_to :income
belongs_to :projection
end
class Projection < ActiveRecord::Base
has_many :income_projections
has_many :incomes, :through => :income_projections
accepts_nested_attributes_for :income_projections
def update(post_params)
...
def edit
@projection = Projection.find(params[:id])
@incomes = @projection.incomes
end
...
def projection_params
params.require(:projection).permit(:name,
income_projections_attributes: [:id,:projection_id, :amount, :name, '_destroy']
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment