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:
model ContactInfo
has_one :user_info
#or has_many :user_infos
end
Hi..
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
@contactinfo= Contactinfo.find(:all, :joins => "contactinfos inner join
userinfos as u on contactinfos.contact_id=u.id", :conditions =>
["contactinfos.contact_id =?", 25])
Thanks for the reply..
using this query i can able to get only the contactinfo table fields but
i want to get userinfo table fields as well as contactinfo fields
also...
Don't think of merging them into one result set, think of them as two
seperate sets of data (or models) that are related.
That's the way Rails treats the data and it works very well.
I understand that you're new to Rails but take some time to get to
understand Rails way of doing things and your life will be much
easier.