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 para开发者_如何学Pythonmeter (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?
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.
精彩评论