On Wednesday, December 15, 2010 12:50:03 PM UTC-5, rob wrote:
>
> On Dec 15, 2010, at 12:04 PM, Colin Law wrote: > On 15 December 2010 17:01, 
> Tim Shaffer wrote: >> You could just use a method instead... >> >> class 
> User < ActiveRecord::Base >> >> has_many :payments >> >> def 
> testing_payments >> payments.where(:testing => testing) >> end > > That 
> would be even better as a named scope. > > Colin Actually, it would be 
> better if it worked: class User < ActiveRecord::Base has_many :payments def 
> testing_payments payments.where(:testing => true) # testing is a local? end 
> end somebody = User.find(params[:id]) Then, you could say: 
> somebody.testing_payments Or add a scope to Payment class Payment < 
> ActiveRecord::Base belongs_to :user scope :testing, where(:testing => true) 
> end And you'd say: somebody.payments.testing Either would work. If testing 
> is a instance method of User, then the original suggestion might actually be 
> "better." -Rob Rob Biedenharn [email protected] 
> http://AgileConsultingLLC.com/ [email protected] 
> http://GaslightSoftware.com/ 


The problem with this is that he doesn't want to find Payments where testing 
= true, he wants to find Payments where testing = value of testing attribute 
for the User instance.

-- 
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 this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to