0

when I submit the form :

Parameters: {"authenticity_token"=>"LJ/ZME2lHZ7VwCDgPKX6OFe326fXSXo5UB4M0cPwbCE=", "project_id"=>"second", "utf8"=>"✓", "commit"=>"Add Todo", "esthour"=>{"rfp_id"=>"2", "cms_est_hours"=>"", "modul1hours_attributes"=>{"0"=>{"module_est_hours"=>"11", "modul1_id"=>"3"}, "1"=>{"module_est_hours"=>"111", "modul1_id"=>"4"}}, "designpages_est_hours"=>"", "ecommerce_est_hours"=>""}}

models

class Esthour < ActiveRecord::Base
  has_many :modul1hours
  accepts_nested_attributes_for :modul1hours
end

class Modul1hour < ActiveRecord::Base
  belongs_to :esthour
  attr_accessible :module_est_hours,:module_act_hours,:modul1_id,:esthour_id
end

view

<% @m1.map(&:id).each do |id|%>

  <%= b.fields_for :modul1hours, @esthour.modul1hours.build do |f| %>

    <%= f.hidden_field :modul1_id, :value => id %>

    <%= f.text_field :module_est_hours, :size => 30 %>
    </tr>
  <% end %>

<% end %>

controller

def new
  @esthour = Esthour.new
  @project = params[:project_id]
  respond_to do |format|
    format.html # new.html.erb
    format.json { render :json => @esthour }
  end
end

You can see my earlier question regarding this.

I'm waiting for valuable reply. Thanks.

5
  • Please post your create action in addition to the new action you've already posted. Commented Dec 12, 2013 at 14:22
  • def create @project = params[:project_id] @esthour = Esthour.new(params[:esthour]) respond_to do |format| if @esthour.save format.html { redirect_to project_rfp_url(@project,@esthour.rfp_id), :notice => 'hours was successfully created.' } format.json { render :json => @esthour, :status => :created, :location => @esthour } else format.html { render :action => "new" } format.json { render :json => @esthour.errors, :status => :unprocessable_entity } end end end Commented Dec 12, 2013 at 14:28
  • are there any errors reported. When you check your log file do you see the correct insert query? Commented Dec 12, 2013 at 15:04
  • @Anish please edit your post, and add the action code in it. Commented Dec 13, 2013 at 9:54
  • @vinodadhikary there is no error,@majioa action code is already there Commented Dec 16, 2013 at 5:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.