I think what [email protected] pointed out is most poignant, you can accomplish 
what you are trying to accomplish with this (ruby 2 syntax)

scope :low_level, -> { where(:level => 1) }


The you reference this scope as Article.low_level

as you get your hands dirty with AR scopes, read & understand what "lazy 
evaluation" is in the query lifecycle.

here's a good post about it: 
http://railsadventures.wordpress.com/2012/11/09/activerecord-lazy-scope-evaluation/






On Sep 24, 2014, at 5:18 PM, Jan Yo <[email protected]> wrote:

> Jason Fb wrote in post #1158388:
>> 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.
> 
> Good point
> 
>> 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)?
> 
> I did that just to share code
> 
>> 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.
> 
> Good idea
>> 
>> -Jason
> 

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/69304FC0-CDA3-4B15-9A7B-7976ECB0CB3E%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to