Jak wywoływać metody zdefiniowane w ApplicationController w modelach
Zdefiniowałem metodę w ApplicationController
<code>class ApplicationController < ActionController::Base helper_method :get_active_gateway def get_active_gateway(cart) cart.account.gateways end end </code>
Kiedy nazywam tę metodę w modelu
<code>class Order < ActiveRecord::Base def transfer active= get_active_gateway(self.cart) end end </code>
To błąd rzucaniaundefined local variable get_active_gateway
.
Więc napisałem
<code>class Order < ActiveRecord::Base def transfer active= ApplicationContoller.helpers.get_active_gateway(self.cart) end end </code>
Potem rzucałerror undefined method nil for Nilclass
.
Pracuję w Railsach 3.2.0.