如何找到ActionMailer方法接受的参数数量?

时间:2014-06-02 01:27:48

标签: ruby-on-rails ruby ruby-on-rails-4 actionmailer

我想查找ActionMailer方法接受的参数数量。

我的邮件代码:

UserMailer < ActionMailer::Base
  def signup(arg1)
  end
end

我试过(在rails控制台中):

# NameError: undefined method `UserMailer.signup' for class `Object'
method('UserMailer.signup').arity

# NameError: undefined method `signup' for class `Class'
UserMailer.method('signup').arity

# NoMethodError: private method `new' called for UserMailer:Class
UserMailer.new.method('signup').arity

1 个答案:

答案 0 :(得分:2)

这应该这样做:

UserMailer.instance_method(:signup).arity