Created
March 13, 2015 15:05
-
-
Save anonymous/b25123b9a029968e904b to your computer and use it in GitHub Desktop.
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
<%= f.fields_for :incomes do |income| %> | |
<%= income.label :name %> | |
<%= income.text_field :name %> | |
<%= income.label :amount %> | |
<%= income.text_field :amount %> | |
<% end %> |
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
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"} |
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
class Income < ActiveRecord::Base | |
has_many :income_projections | |
has_many :projections, :through => :income_projections | |
accepts_nested_attributes_for :income_projections | |
end |
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
income_projection.rb | |
class IncomeProjection < ActiveRecord::Base | |
belongs_to :income | |
belongs_to :projection | |
end |
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
class Projection < ActiveRecord::Base | |
has_many :income_projections | |
has_many :incomes, :through => :income_projections | |
accepts_nested_attributes_for :income_projections | |
def update(post_params) | |
... |
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 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