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

cannot reuse it in the .js.erb

Why not? Seems like that would be the easiest option.

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 !

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs