Aufrufen von in ApplicationController definierten Methoden in Modellen
Ich habe Methode in ApplicationController definiert
<code>class ApplicationController < ActionController::Base helper_method :get_active_gateway def get_active_gateway(cart) cart.account.gateways end end </code>
Wenn ich diese Methode im Modell aufrufe
<code>class Order < ActiveRecord::Base def transfer active= get_active_gateway(self.cart) end end </code>
Es warf Fehlerundefined local variable get_active_gateway
.
Also schrieb ich
<code>class Order < ActiveRecord::Base def transfer active= ApplicationContoller.helpers.get_active_gateway(self.cart) end end </code>
Dann warf eserror undefined method nil for Nilclass
.
Ich arbeite in Rails 3.2.0.