开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜