这就是我的错误
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
产生这个冲突的行在user
模型
has_many :events_created, :through => :events, :source => :author
总而言之,我知道上述错误的发生是因为在event
模型中有以下行(在我的db中搜索events.user_id
而不是events.author_id
belongs_to :author, :class_name => "User"
是否有办法使它搜索events.author_id
在这个集合?
belongs_to :author, :class_name => "User", :foreign_key => "author_id"