selzlein said over 6 years ago on Page Specific Javascript in Ruby on Rails :

Great work, thank you!

I have implemented the controller action specific CoffeeScript approach. Therefore I have 1 .coffee file per controller action. However I stumbled upon an issue... let's say I have a controller with a 'new' action and a respective '' script. When I submit the 'new' page that triggers Rails validation errors, the controller action gets updated to 'create', since it was a Post. Therefore '' won't execute while my controller renders 'new.html.erb' directly, not through a redirect, as is standard Rails scaffold.

In this case what would you recommend? Should I simply use the 1 file per controller approach?