1
votes

I am having errors when using the where method

Project.where('projectid=10').first

It give me this :

NoMethodError: undefined method where' for #<Class:0xb6ee1144> from /home/rvb/2011/January/desaldata/vendor/rails/activerecord/lib/active_record/base.rb:1672:in method_missing_without_paginate' from /home/rvb/2011/January/desaldata/vendor/gems/mislav-will_paginate-2.3.6/lib/will_paginate/finder.rb:167:in `method_missing' from (irb):3

I'm using Rails 2.1.1 .. Is the where method not available in this rails version?

2

2 Answers

1
votes

'Where' method is only available in rails 3.0.0 or above....

1
votes

If you do upgrade to Rails (or just ActiveRecord) 3.0, change your query to this:

Project.where(:projectid => 10).first

Also, change the name of 'projects'.'projectid', to 'projects'.'id'.