Controller是Pms :: Grn,我想为Pms :: Srn创建一条记录 如果Grn的一个参数提供了如何实现它的代码
控制器
class Pms::GrnsController < Pms::PmsModulesController
def create
@pms_grn = Pms::Grn.new(pms_grn_params)
respond_to do |format|
if @pms_grn.save
if params[:pms_grn][:rejected_qty].present?
@pms_srn = Pms::Srn.create()# here I want to create record for
# pms_srn with it's nested model
end
end
end
end
模型
class Pms::Srn < ActiveRecord::Base
has_many :pms_srn_inventories
accepts_nested_attributes_for :pms_srn_inventories
end