I'm in the process of adding AJAX to a Rails app. One obstacle I have is updating the flash. I need all my AJAX requests to update the flash if my controller sets the flash with a message that I want shown on my page. So far I've converted 4 actions to AJAX, but there are at least 10 more. Customizing each action to update the flash message gets very tedious. So I need a way of DRYing it up.
For my templates, I'm using js.erb extensions (e.g. a request to /articles/create.js
would render the app/views/articles/create.js.erb
template).
At the top of each template, I put some javascript code with some helper code: