【发布时间】:2013-12-06 13:31:55
【问题描述】:
我的应用程序中有两个表
rfp.rb
has_many :rfp_hors
attr_accessible :rfp_hors_attributes
accepts_nested_attributes_for :rfp_hors, :allow_destroy => true
rfp_hor.rb
attr_accessible :numberofmenu_est_hours,
:numberofmenu_act_hours,
:browser_est_hours,
:browser_act_hours,
:numberofpage_est_hours,
:numberofpage_act_hours,
:rfp_id
belongs_to :rfp
当我提交 rfp_hors 时,参数在控制台中显示如下
Parameters: {"rfp_hor"=>{"ecommerce_est_hours"=>"7", "rfp_id"=>"13", "designcomplexity_est_hours"=>"3", "browser_est_hours"=>"4", "framworks_est_hours"=>"5", "cms_est_hours"=>"6"}, "utf8"=>"✓", "commit"=>"Create Rfp hor", "authenticity_token"=>"XXgQlufpBP2lvcde/EiFIx93aM5Ov47MNFqsCkLun2Y="}
和控制器 rfps.rb
def show
@rfp = Rfp.find(params[:id])
@rfp_hor = RfpHor.new
end
rfp_hors.rb
def create
@rfp_hor = RfpHor.create(params[:rfp_hor])
respond_to do |format|
if @rfp_hor.save
format.html { redirect_to rfp_url(@rfp_hor.rfp_id), :notice => 'rfp hour was successfully created.' }
format.json { render :json => @rfp_hor, :status => :created, :location => @rfp_hor }
else
format.html { render :action => "new" }
format.json { render :json => @rfp_hor.errors, :status => :unprocessable_entity }
end
end
结束
在 rfp_hors 中的数据库 aceept rfp_id 中的所有内容都保存得很好 任何帮助都将非常感谢提前
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 forms