Ruby on Rails
Wednesday, September 24, 2014
Jan,
That is pretty strange-- but it looks like you're doing something non-standard and you've gotten yourself into a pickle.
I notice that the error message says there's no method 'where' on an instance of an Article. Normally you call where on the class itself.
First of all, why is your class named "X" in your example (did you do that just to share you code? It's a little confusing)?
Secondly, can you show us the calling code please?
Finally, put a debugging statement inside of self.low_level and then type "self" to understand the context (scope) of how it is called -- if "self" inside the method is actually your Article class or (somehow) an instance of an Article.
-Jason
On Sep 24, 2014, at 10:13 AM, Jan Yo <lists@ruby-forum.com> wrote:
Rspec forum isn't working
Rspec is having trouble recognizing where method.
Here's the rspec output:
NoMethodError:
undefined method `where' for #<Article:0x000000066ceb38>
#
/apps/rvm/gems/ruby-2.0.0-p481/gems/activemodel-4.0.10/lib/active_model/attribute_methods.rb:439:in
`method_missing'
#
/apps/rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.0.10/lib/active_record/attribute_methods.rb:168:in
`method_missing'
#
/apps/rvm/gems/ruby-2.0.0-p481/gems/activerecord-4.0.10/lib/active_record/querying.rb:9:in
`where'
The spec calls index which then calls a public method that uses the
following method:
class X < ActiveRecord::Base
def self.low_level
where(:level=> 1)
end
end
Any ideas what could be the problem?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment