The unobtrusive javascript plugin stores its generate javascript files
in the session.
But it has some issues currently putting things into the wrong session
(because it doesn’t check to see what session key is being set in the
application controller). As such, it doesn’t work unless you
explicitly set the session key.
Currently I just added a line to my application controller like so:
UnobtrusiveJavascriptController.send :session, :session_key =>
‘_reminders_session_id’
I’d like to fix the UJS plugin and submit a patch, but I’m not sure
how to best go about it.
You can’t simply change the UnobtrusiveJavascriptController to derive
from ApplicationController because it won’t know what it is when it
loads. So possibly you could do this, but specify a dependency or
order of loading?
Otherwise within the UJS controller you could set the session key to
match the application. The only way I have been able to get this to
work is the following:
session :session_key =>
ApplicationController.session.first[:session_key]
But this seems fragile and inelegant to say the least.
Comments, suggestions?