Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get rid of a Rails warning: "multiple values for a block parameter (0 for 1)"

I'm getting these warnings:

payment_method.rb:11: warning: multiple values for a block parameter (0 for 1)
payment_method.rb:12: warning: multiple values for a block parameter (0 for 1)

payment_method.rb lines 11 and 12:

class PaymentMethod < ActiveRecord::Base
  ...
  named_scope :expiring_next_month, lambda {|pm| {:conditions => {:ed => DateTime.now.beginning_of_month}}}
  named_scope :expired, lambda {|pm| {:conditions => ["ed < ?", DateTime.now.beginning_of_month]}}
  ...
end

What am I missing here?

like image 828
marcgg Avatar asked Jan 21 '26 08:01

marcgg


1 Answers

You have a params on your scope. You need use it. Or not define it

named_scope :expiring_next_month, lambda { {:conditions => {:ed => DateTime.now.beginning_of_month}}}
named_scope :expired, lambda { {:conditions => ["ed < ?", DateTime.now.beginning_of_month]}}

With my case you can call without args. Not in your case. In ruby 1.8 there are no way to have optionnal params in lambda.

like image 177
shingara Avatar answered Jan 23 '26 01:01

shingara