ruby on rails 3 - Rails3: Getting "no attribute named..." in simple join -


After

I'm trying to join for the first time in Rails 3, and can not get it The most basic thing to do is to work, so some prominent must be remembered.

  class members & lt; ActiveRecord :: base belongs_to: status ... end class status ActiveRecord :: base has_many: members ... end   

When I try to use a join, test in console An example optimized rail guide

  time_range = (Time.now.midnight - 1.day) .. Time.now.midnight Status.joins (members) .where ('member.created_at '= & Gt; time_range)   

I get an error message,

  ActiveRecord :: StatementInvalid: Mysql2 :: error: unknown column' member. 'Where segment' in created_at ': Include `statuses` * from` statuses` within `` members```status_id` = `statuses`.`id` (` members`.created_at` between members' 2011-03- 26 23:00 : 00 'and' 2011-03-27 23:00:00 ')   

Both models do is created_at column and it Works: member. Where (: created_at => time_arange) . I have tried many permutations and have used different columns, but whenever I try to join it, same unknown column gets error

This should be done members.created_at :) Remember you use the name of the DB table clearly, that it is in plural by the rail conference.

Comments