gemgento/rails_script — pull request #1 by darkphnx (2014-10-29 16:21:10+00:00)
Title: to_javascript helper method for controllers

I love what this Gem is doing. I was just integrating it into a project where I identified a need to add some variables in the application controller, and some others in the page controller.

Instead of checking that `@to_javascript` was set and then merging the hashes I wrote a small concern to take care of it for me.

You can now call the `to_javascript` method multiple times from your controller to append your new data to the to_javascript array. For example:

```ruby
class ApplicationController < ActionController::Base
before_action do
to_javascript username: @current_user.username, account: @current_account.name
end
...
end
```

```ruby
class ProjectsController < ApplicationController
before_action do
to_javascript project_name: @project.name
end
end