Where to place JS examples provided in "Working with JavaScript" Rails guide

I’m just working my way through the rails guide “Working with Javascript in Rails” and I am coming across numerous js code snippets containing things like eventListeners. I think the guide should state current best practice as to where that js code goes? Should it go into a new file created in the app/javascript/packs directory and if so what should that file be called? Should it go into a view returned by a controller action? Should it go somewhere else? I think it would be helpful in general to state an example file location of any code snippet provided in the rails guides (Although sometimes that wouldn’t be applicable).

1 Like

Recently I have gone through this blog post which was helpful : Organizing Javascript in Rails Application with Turbolinks | Brandon Hilkert

I think we should have a rails guides talking about the possible options for organising JS code in a rails application.