javascript file structure

even when it works, i must say that i find a little disorder. cuz, as i
said before, this JS code is more ralated to the "view". so, i really
think that this will be a better structure:

app/views/posts/edit.html.erb
app/views/posts/new.html.erb
app/views/posts/edit.js
app/views/posts/new.js

¿is there an easy a way to make this structure?
¿how and where i must include these js files?
¿wich is the best rails practice for such a thing?

Rails doesn't really do much for you here - it's expecting js can be
served out of the document root (ie the public folder)
As far as I know you're pretty much on your own here. One way would be
to have a rake task or similar that consolidates all of those small js
files into a single all.js file which the user's browser can download
and cache once and for all - only all.js would need to be in public/
javascripts

Fred

Or is this way correct?

In your helper code like

def js_to_be_included
   %{
       <script>
           function test_function{