Note that there are some explanatory texts on larger screens.

plurals
  1. POrails formtastic nested form WARNING: Can't mass-assign protected attributes
    primarykey
    data
    text
    <p>I've following models:</p> <pre><code>class CapstoneMilestone &lt; ActiveRecord::Base attr_accessible :capstone_id, :milestone_id, :rank, :id, :status, :statusweight, :rating, :ratingweight belongs_to :milestone belongs_to :capstone accepts_nested_attributes_for :capstone, :allow_destroy =&gt; false accepts_nested_attributes_for :milestone, :allow_destroy =&gt; false end class Milestone &lt; ActiveRecord::Base has_many :capstone_milestones has_many :capstones, :through =&gt; :capstone_milestones attr_accessible :id, :name, :description, :department_id, :project accepts_nested_attributes_for :capstone_milestones, :allow_destroy =&gt; true end </code></pre> <p>I also have a formtastic form:</p> <pre><code>&lt;% semantic_form_for(@capstone_milestone) do |form| %&gt; &lt;%= form.semantic_errors :state %&gt; &lt;% form.inputs do %&gt; &lt;%= form.input :capstone_id , :as =&gt; :select, :collection =&gt; Capstone.all %&gt; &lt;%= form.input :milestone_id, :as =&gt; :select, :collection =&gt; Milestone.all %&gt; &lt;%= form.input :status, :as =&gt; :numeric%&gt; &lt;%= form.input :statusweight, :as =&gt; :numeric%&gt; &lt;%= form.input :rating, :as =&gt; :numeric%&gt; &lt;%= form.input :ratingweight, :as =&gt; :numeric%&gt; &lt;% end %&gt; &lt;%= form.inputs :name, :for =&gt; :milestone%&gt; &lt;%= form.buttons %&gt; &lt;% end %&gt; </code></pre> <p>And my capstone_milestone controller (should) take care of the update:</p> <pre><code> def update @milestone=@capstone_milestone.milestone # I also removed these 2 lines without success @milestone.update_attributes(params[:milestone_id]) respond_to do |format| if @capstone_milestone.update_attributes(params[:capstone_milestone]) format.html { redirect_to(session[:return_to], :notice =&gt; 'Milestone was successfully updated.') } format.xml { head :ok } else format.html { render :action =&gt; "edit" } format.xml { render :xml =&gt; @capstone_milestone.errors, :status =&gt; :unprocessable_entity } end end end </code></pre> <p>When I submit the form, the capstone_milestone is update but the linked milestone is not.</p> <p>This is the server log:</p> <pre><code>Started POST "/capstone_milestones/12" for 127.0.0.1 at 2011-03-18 11:40:30 +0100 Processing by CapstoneMilestonesController#update as HTML Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"ZkErrLTpdp56BASPdZiiT6ZcvUx5KsI+Gm3JLnzM6D0=", "capstone_milestone"=&gt;{"capstone_id"=&gt;"100001", "milestone_id"=&gt;"100002", "status"=&gt;"80.0", "statusweight"=&gt;"1.0", "rating"=&gt;"", "ratingweight"=&gt;"1.0", "milestone_attributes"=&gt;{"name"=&gt;"Land Control Analysis 2", "id"=&gt;"100002"}}, "commit"=&gt;"Update Capstone milestone", "id"=&gt;"12"} User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 3 LIMIT 1 CapstoneMilestone Load (0.4ms) SELECT `capstone_milestones`.* FROM `capstone_milestones` WHERE `capstone_milestones`.`id` = 12 ORDER BY capstone_milestones.rank LIMIT 1 Milestone Load (0.3ms) SELECT `milestones`.* FROM `milestones` WHERE `milestones`.`id` = 100002 LIMIT 1 SQL (0.1ms) BEGIN SQL (0.1ms) COMMIT SQL (0.1ms) BEGIN WARNING: Can't mass-assign protected attributes: milestone_attributes </code></pre> <p>Any idea, suggestion to unblock me would be greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload