Note that there are some explanatory texts on larger screens.

plurals
  1. POdata not saved in nested table with hidden (array) field passed
    primarykey
    data
    text
    <p>when I submit the form : </p> <pre><code>Parameters: {"authenticity_token"=&gt;"LJ/ZME2lHZ7VwCDgPKX6OFe326fXSXo5UB4M0cPwbCE=", "project_id"=&gt;"second", "utf8"=&gt;"✓", "commit"=&gt;"Add Todo", "esthour"=&gt;{"rfp_id"=&gt;"2", "cms_est_hours"=&gt;"", "modul1hours_attributes"=&gt;{"0"=&gt;{"module_est_hours"=&gt;"11", "modul1_id"=&gt;"3"}, "1"=&gt;{"module_est_hours"=&gt;"111", "modul1_id"=&gt;"4"}}, "designpages_est_hours"=&gt;"", "ecommerce_est_hours"=&gt;""}} </code></pre> <p><strong>models</strong></p> <pre><code>class Esthour &lt; ActiveRecord::Base has_many :modul1hours accepts_nested_attributes_for :modul1hours end class Modul1hour &lt; ActiveRecord::Base belongs_to :esthour attr_accessible :module_est_hours,:module_act_hours,:modul1_id,:esthour_id end </code></pre> <p><strong>view</strong></p> <pre><code>&lt;% @m1.map(&amp;:id).each do |id|%&gt; &lt;%= b.fields_for :modul1hours, @esthour.modul1hours.build do |f| %&gt; &lt;%= f.hidden_field :modul1_id, :value =&gt; id %&gt; &lt;%= f.text_field :module_est_hours, :size =&gt; 30 %&gt; &lt;/tr&gt; &lt;% end %&gt; &lt;% end %&gt; </code></pre> <p><strong>controller</strong></p> <pre><code>def new @esthour = Esthour.new @project = params[:project_id] respond_to do |format| format.html # new.html.erb format.json { render :json =&gt; @esthour } end end </code></pre> <p><strong>You can see my earlier question regarding</strong> <a href="https://stackoverflow.com/questions/20539040/pass-array-hidden-field-in-nested-model-rails">this</a>.</p> <p>I'm waiting for valuable reply. Thanks.</p>
    singulars
    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