Erwin
2011-May-30 09:25 UTC
keeping a controller clean ... how to use a view helper in my controller
there is some case we have to reuse a helper method to produce an
html output...
in my form view , I am calling a user_helper method fees_string() to
output a specific string based on user membership
%span#academy_analysis_fees
= fees_string( 1, @academy_account_type )
but on changing a dropdown value , I need to modify this fee string,
with an Ajax request change_language
in my user_controller.rb
.....
def change_language # POST js request......
account_type = new academy_account_type # get the new account
type
# I should be able to call the fees_string() method to get an
html string used in my change_language.js.erb
# rather than rebuilding the string
fees_string = (account_type.locale[:currency_symbol] + "
" ...........
this runs well but is there any way to reuse the helper method...
cannot reuse it in the .js.erb
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Tim Shaffer
2011-May-30 11:01 UTC
Re: keeping a controller clean ... how to use a view helper in my controller
> cannot reuse it in the .js.erbWhy not? Seems like that would be the easiest option. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Erwin
2011-May-30 13:57 UTC
Re: keeping a controller clean ... how to use a view helper in my controller
I tried .. but I did it wrong .. ..according to your feedback .. I re-tested .. and it works .. my error : passing the helper method as a variable <%@fees_string( 1, @academy_account_type ) %> bad ! I just corrected it : <%= fees_string( 1, @academy_account_type ) %> and it works .... ned to rest a little bit thanks a lot ! On 30 mai, 13:01, Tim Shaffer <timshaf...-BUHhN+a2lJ4@public.gmane.org> wrote:> > cannot reuse it in the .js.erb > > Why not? Seems like that would be the easiest option.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.