On 15 November 2012 17:56, Jordon Bedwell <[email protected]> wrote:
> On Thu, Nov 15, 2012 at 11:15 AM, Colin Law <[email protected]> wrote:
>> I was trying to ask the general question, that if one has a scope and
>> a class method that perform exactly the same operation (such as the
>> example in this thread), so
>>
>> scope :today_reservations, lambda {   where("reserved_from > ? and
>> reserved_to <= ?", Date.today,  Date.today ) }
>>
>> and
>>
>> self.today_reservations
>>   where("reserved_from > ? and reserved_to <= ?", Date.today,  Date.today ) }
>> end
>>
>> Is there actually any difference between the two, or is the former
>> just a way of defining the latter in a railsy sort of way?
>
> From what I remember briefly while playing (since I have always
> preferred the latter) scope is like attr_writer and attr_reader in
> that it's all the same in the end one just gives you more control over
> the flow, the other does it all for you but in the end, the result is
> exactly the same.

OK, thanks

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to