I had some common bits of RJS that I was repeating in multiple RJS files, and so wanted to put it into a helper.
I added a method to app/helpers/application_helper.rb just like I would normally for an html.erb file. The method works, except that it can't call view helpers that the RJS file could.
One of the lines that worked in the RJS file was:
notices = flash.collect { |type,msg| content_tag(:p, msg, :class => type) }
But content_tag is not accessible from the RJS helper. Why not, and how do I access it from there?
what about something like this?
You have to use
view_helpers
in any method you call from rjs too, which is not very nice, but I tried it in the model (got projects only in 2.3 and 3.1) and that worked...