For getting a datum from 2 tables, I have used include as follows,
Admin:
belongs_to :user
User:
has_many :admins
There was a condition that i have to sort names of admins, where the names of admins will be in user table.
Hence,
Admin.find(:all, :include=>"user", :order => "users.name")
I felt this easy than sqls, & interesting
1 comment:
Hmmm it looks really nice. I'm just starting with RoR. I can share some opinion later.
Regards, Paweł Wojciechowski
Outsourcing IT - Konopnickiej.Com
Post a Comment