Announcement (2017-05-07): www.ruby-forum.com is now read-only since I
unfortunately do not have the time to support and maintain the forum any
more. Please see rubyonrails.org/community and ruby-lang.org/en/community
for other Rails- und Ruby-related community platforms.

I am looking for how to create a dynamic JavaScript within Rails and
coming up empty. I am sure this is probably covered somewhere but I
am jost not having any luck finding it.
Basically, I want a controller that creates a JavaScript that can be
included by HTML outside of the Rails app. This JavaScript need to
take into account the Rails session information.
Can someone point me in the right direction?

On 12/12/05, Jackson Miller <jackson@tekzen.net> wrote:
> I am looking for how to create a dynamic JavaScript within Rails and> coming up empty. I am sure this is probably covered somewhere but I> am jost not having any luck finding it.>> Basically, I want a controller that creates a JavaScript that can be> included by HTML outside of the Rails app. This JavaScript need to> take into account the Rails session information.
I've done this myself. Here is what you need to do.
1. Create a custom controller (I used "CustomJavaScript"). If you use
just javascript, I believe it will interfere with the regular
javascript folder. I didn't try it out though.
2. Create a method / view for each dynamic javascript.
3. Fill out the view with the javascript, interspercing the dynamic
information where needed.
4. You might need to overwrite the default headers for the files to
be served correctly.
5. Link to the dynamic javascript using /ControllerName/MethodName
Enjoy! Let me know if you have more difficulties.