[ruby-it] usare un metodo dal controller e dalla vista
Antonio Cangiano
acangiano a gmail.com
Dom 8 Mar 2009 22:21:23 CET
On Sun, Mar 8, 2009 at 5:16 PM, Sam Pei <tex---74 a libero.it> wrote:
> Salve a tutti
>
> Forse mi sto perdendo in un bicchier d'acqua, ma come si fa ad usare un
> metodo sia dal controller che dalla vista?
>
Dichiara il metodo nel controller (ad esempio in ApplicationController) e
poi usa helper_method per renderlo un helper disponibile nella vista.
Esempio:
class ApplicationController < ActionController::Base
helper_method :my_method
def my_method
# ...
end
end
Ciao,
Antonio
--
http://antoniocangiano.com - Zen and the Art of Programming
http://math-blog.com - Mathematics is wonderful!
http://stacktrace.it - Aperiodico di resistenza informatica
Follow me on Twitter: http://twitter.com/acangiano
Author of "Ruby on Rails for Microsoft Developers" (Wrox, 2009)
More information about the Ml
mailing list