I would like to make rails render actions via AJAX. I’ve read about respond_to and js.erb. But I really don’t feel like going through every link_to and add :remote => true
But my main concern is creating almost identical js.erb files.
Is there a rails way of making an AJAXful website? Maybe something like inherited_resources?
The :remote => true bit on the link adds a data-remote attribute to the resulting HTML link.
Then there’s the rails ujs driver that unobtrusively pick this up through the proper selector and adds the required headers to let Rails (ActionPack) understand that this is an AJAX request.
One solution might be to set, depending on the driver, all links to be AJAX (not sure if you want to do that) through Javascript or overriding/expanding/creating another helper method that has the :remote => true set.
Something around those lines:
Expand to include html options, etc, at will.
Or with alias_method_chain (untested):