Does anyone know the way, or a place where I can find out how to do this?
Basically, all I want to do is connect a foreign key between two tables.
Is it true, that all I have to do is write the “belongs_to” and “has many” ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You also need to ensure that a column exists for the foreign key in the database table associated with the Class that says it “belongs_to” the other one. So for the classes…
…Rails assumes that your
treestable has aforest_idcolumn. You can then do, for example,Here’s a great place to get the info you need: http://guides.rubyonrails.org/association_basics.html