Hmm, maybe I’m confused. Even if I used your solution verbatim I think I’m still stuck with the problem as update.html.erb would not be used (edit.html.erb would).
To recap, what you’re suggesting is essentially what I’m doing – except instead of hard-coding “people/update” I’m using a helper method that uses controller.controller_name + “/” + controller.action_name to generate that part of the path.
So far so good, but when I use “render :edit” in the “update” action, I’ve got my problem (I’m requesting the wrong action’s assets).
No, in the solution I suggested the decision about which assets to use is made in the template and can’t depend on the controller name/action. There’s no way that I know of to determine the template name in the same way via a helper function.
The only other option that might be useful for you would be to have combined CSS/JS files for some actions where this type of thing can occur like with update/edit and set the ID or class of the tag based on the template rendered. You could then target selectors in your assets to ensure the correct behavior, but this might end up being more effort than a simpler solution.
Just to add my two cents, the body approach works well as long as you work with classes, not a single id, not with the id. Something like action_youractionname and controller_yourcontrollername. Modernizr has a similar approach to specify what features are available.
I am using a custom page_css class set in the controller action method here instead of an action name, but I would use an action name instead these days
This may look like a quick and dirty way to do this, but might work with minimal effort.
Also, this will work only in the scenario where create and update never have their own views - this would be the case most often, but just wanted to highlight it