我在ApplicationController中定义的方法
class ApplicationController < ActionController::Base
helper_method :get_active_gateway
def get_active_gateway(cart)
cart.account.gateways
end
end
当我打电话模型这种方法
class Order < ActiveRecord::Base
def transfer
active= get_active_gateway(self.cart)
end
end
它抛出错误undefined local variable get_active_gateway
。
所以我写了
class Order < ActiveRecord::Base
def transfer
active= ApplicationContoller.helpers.get_active_gateway(self.cart)
end
end
然后,它被扔error undefined method nil for Nilclass
。
我用Rails 3.2.0的工作。