0

Ok this is the error that I have

Mysql2::Error: Unknown column 'events.user_id' in 'where clause': SELECT `users`.* 
FROM `users` INNER JOIN `events` ON `users`.`id` = `events`.`author_id`  
WHERE `events`.`user_id` = 1

The line that generates this conflict is in the user model

has_many :events_created, :through => :events, :source => :author

All in all I know that the above error happens because in the event model there is the following line (which searches for a events.user_id in my db instead of the events.author_id

belongs_to :author, :class_name => "User"

Is there any way to make it search for the events.author_id in this collection?

4

1 回答 1

1
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
于 2013-01-06T16:48:07.227 回答