I have three models:
class User < ActiveRecord::Base has_many :basiccases end class Basiccase < ActiveRecord::Base belongs_to :user belongs_to :form3_c end class Form3C < ActiveRecord::Base has_one :basiccases end How can I add a new Form3C to the Basiccase? Do I need to use a Basiccase controller or Form3C controller to create a form? If I use Form3cController how can I set the foreign key in the BasiccaseController?
has_onerelation should go into a model, not a controller. So if you have aForm3Cmodel class, try to add there the relation. Thehas_onerelation should go to singular as inhas_one :basiccase. You would normally build theBasiccasefrom theForm3Cinstance:self.build_basiccasewill build the basiccase thatbelongs_toForm3C.