I have
add_column :foos, :bar_id, :integer
but I wast to be able to do stuff like
@foo.bar.name
rather than
Bar.find(@foo.bar_id)
I think its done with t.references when creating a table… but how do a add it post-table-creating?
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 have to edit corresponding model file and add there for example
belongs_todeclaration. This is exactly what allows you to call the@foo.bar.name.