Created
October 27, 2012 18:01
-
-
Save lazypower/3965530 to your computer and use it in GitHub Desktop.
Problematic Mass Assignment
This file contains hidden or 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
<div class="field"> | |
<%= f.label :notes %><br /> | |
<%= f.text_area :notes %> | |
</div> | |
<div class="field"> | |
<%= f.fields_for :rinkleagues do |builder| %> | |
<fieldset> | |
<%= builder.label :rinkleague, "Leagues" %> | |
<%= builder.collection_select :RinkLeague, RinkLeague.all, :value, :display %> | |
</fieldset> | |
<% end %> | |
</div> |
This file contains hidden or 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
Can't mass-assign protected attributes: rinkleagues, rinksurfaces, developmentalprograms | |
app/controllers/rinks_controller.rb:43:in `new' | |
app/controllers/rinks_controller.rb:43:in `create' | |
{"utf8"=>"✓", | |
"authenticity_token"=>"x1fV0Snf9A7f2938b/UplmuVFRvPytZSPlCzxO07KPw=", | |
"rink"=>{"name"=>"", | |
"address1"=>"", | |
"address2"=>"", | |
"addresscity"=>"", | |
"addressstate"=>"", | |
"addresszip"=>"", | |
"phone1"=>"", | |
"phone2"=>"", | |
"website"=>"", | |
"surfacecount"=>"", | |
"indoor"=>"0", | |
"openhockey"=>"0", | |
"sticktime"=>"0", | |
"proshop"=>"0", | |
"notes"=>"", | |
"rinkleagues"=>{"RinkLeague"=>"youth"}, | |
"rinksurfaces"=>{"RinkSurface"=>"ice"}, | |
"developmentalprograms"=>{"DevelopmentalProgram"=>"youth"}}, | |
"commit"=>"Create Rink"} |
This file contains hidden or 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 Rink < ActiveRecord::Base | |
attr_accessible :address1, :address2, :addresscity, :addressstate, :addresszip, :indoor, :name, :notes, :openhockey, :phone1, :phone2, :proshop, :sticktime, :surfacecount, :website | |
attr_accessible :rinkleagues_attributes, :rinksurfaces_attributes, :developmentalprograms_attributes | |
has_many :RinkLeagues | |
has_many :RinkSurfaces | |
has_many :DevelopmentalPrograms | |
accepts_nested_attributes_for :RinkLeagues | |
accepts_nested_attributes_for :RinkSurfaces | |
accepts_nested_attributes_for :DevelopmentalPrograms | |
end |
This file contains hidden or 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 RinkLeague < ActiveRecord::Base | |
attr_accessible :display, :value | |
belongs_to :Rink | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment