Creating an instance in rails association
- by Sandeep Rao
I have three models where a basiccase has a form. Basic case can create a new form.
class User < ActiveRecord::Base
has_many :basiccases
end
class Basiccase < ActiveRecord::Base
belongs_to :user
has_one :basiccases
end
class Form3C < ActiveRecord::Base
belongs_to :basiccases
end
I want to create an instance of form 3c in the form3c controller. Can any one explain me how I can carry the basiccase_id to the form3c controller to set the foreign key attribute.
I can set the value using @basiccase.build_form3_c but I'm not sure how I can get the basiccase_id from the basiccase.