Creating an instance in rails association

Posted by Sandeep Rao on Stack Overflow See other posts from Stack Overflow or by Sandeep Rao
Published on 2012-03-24T21:10:21Z Indexed on 2012/03/25 5:30 UTC
Read the original article Hit count: 140

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.

© Stack Overflow or respective owner

Related posts about ruby-on-rails-3

Related posts about ruby-on-rails-3.1