create table files(id int ai pk, name varchar(255)
create table admins (file_id int, user_id int)
create table users (id int ai pk, name varchar(16),email varchar(255))
I want to get all the admin user names and emails of a given file. Say
for file 1
Admin.where(:file_id=>1).includes(:user). it works very good. Now I
want to sort the admins on the usernames
shows an sql query with an empty column and so bails out. here's the
query I got on the console
SELECT `admins`.`` AS t0_r0, `admins`.`file_id` AS t0_r1,
`admins`.`user_id` AS t0_r2, `users`.`id` AS t1_r0, `users`.`name` AS
t1_r1 FROM `admins` LEFT OUTER JOIN `users` ON `users`.`id` =
`admins`.`user_id` WHERE `admins`.`file_id` = 1 ORDER BY users.name
The first column name is being taken as empty (immediately after the
Is this a bug? I don't want to have id field in the admins table as
that's not useful. How do I write a AR query to sort out this issue
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to email@example.com.
To unsubscribe from this group, send email to firstname.lastname@example.org.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.