Ruby on Rails Thursday, September 25, 2014



On Wednesday, 24 September 2014 10:14:02 UTC-4, Ruby-Forum.com User 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?


There isn't enough code here to know for sure, but something strange is going on with your X class. Line 9 of `active_record/querying.rb` delegates the `where` method to `all`. Normally this is a class method that returns a Relation object. Does your X class have an `all` class method that's overriding that?

--Matt Jones

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/484b4d9e-fd81-49c3-ada2-c1a0d6bd7a35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment