On Thu, Apr 9, 2009 at 12:40 PM, Newb N.
how i should write the below query in rails.i found through mysql
tutorial.i m not pro in rails …so give some lights…
SELECT * FROM contactinfo join userinfo on contactinfo.contact_id =
userinfo.id where contactinfo.user_id = 25
Thanks in advance
It would all depend on the models you’re using.
That db schema is not technically Rails friendly in that the table
names should be user_infos and contact_infos resulting in models named
UserInfo and ContactInfo
Then you could use the following:
#or has_many :user_infos
contact_info = ContactInfo.new 25
user_info = contact_info.user_info
Rails deals with all the sql in the background
“I have never let my schooling interfere with my education” - Mark Twain