Ruby on rails rails中ArgumentError-意外使用arg调用方法

Ruby on rails rails中ArgumentError-意外使用arg调用方法,ruby-on-rails,ruby,Ruby On Rails,Ruby,使用rails 5 我有以下控制器操作: def create enrollment = current_user.enrollments.new(image: enroll_params[:image]) enrollment.send if enrollment.save flash[:notice] = ['It looks like it worked'] flash.keep(:notice) render js: "wind

使用rails 5

我有以下控制器操作:

def create
    enrollment = current_user.enrollments.new(image: enroll_params[:image])
    enrollment.send
    if enrollment.save
      flash[:notice] = ['It looks like it worked']
      flash.keep(:notice)
      render js: "window.location = '#{root_path}'"
    end
  end
它调用以下模型方法:

def send
    response = KairosService.enroll(self)
    self.update_attributes(response: response)
end
当我从浏览器点击控制器操作时,我得到以下错误:

 ArgumentError (wrong number of arguments (given 1, expected 0)):

app/models/enrollment.rb:1:in send'
app/controllers/enrollments_controller.rb:2:in create'
(错误行号将更新以反映代码段)


我不明白为什么会在注册时调用发送操作。新操作?为什么会发生这种情况,以及如何防止调用该操作?

请尝试将
send
重命名为其他对象。您不应该在Ruby中创建名为
send
的方法,因为它是Object()上的标准(也是重要)方法


(这里Rails框架试图调用“真实”发送作为对象创建的一部分,但您的代码覆盖了定义。)

谢谢,就是这样。我不知道Bucked-in-send方法,因此headscratchingRails的最后一个小时充满了元编程,因此它大量使用了
send
之类的东西。