Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Build Status

racovi is a gem to register initialization code for your javascript which is executed only for the current controller and view.

I created that to easily deploy what is explain in this blog post.

racovi is based on the javascript event stack Hevents.

** Important Note ** : This is a early version of the gem and still need some manual installations in your Rails application. But javascript code works


Prepare your Rails layout

Put the helper function init_view_js wherever you want in your layouts, it will add a $(document).ready(…) section calling initializer code for the current controller and the current view.

for example

/** application.html.haml **/
= init_view_js

Prepare your application.js

add these line to your app/assets/javascript/application.js

//= require hevents
//= require racovi

Register an initializer code

use register_init(names,fun) in your controller or view js files

/** assets/javascript/persons.js **/
Racovi.register_init('persons', function(){
  console.log('hello from Person controller')


/** assets/javascript/ **/
Racovi.register_init 'persons', () ->
  console.log('hello from Person controller')

register initializer for multiple views

/** assets/javascript/ **/
Racovi.register_init ['persons_new','persons_edit'], () ->
  console.log('editing a Person')

cumulative initializer for complex views

If you have complex view GUI distributed on multiple sources files, independent from each others, you can register multiple time the same initializer name, all registered functions will be called.

/** assets/javascript/ **/
Racovi.register_init 'persons', () ->
/** assets/javascript/ **/
Racovi.register_init 'persons', () ->
  console.log('hello from Person controller')


  • automatically add hevents and racovi in application.js
  • automatically add init_view_js to layouts
  • make optioneal usage of $document.ready(…)
  • add generic helpers to init whatever event

Contributing to racovi

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.


Copyright (c) 2012 yann ARMAND under MIT See LICENSE.txt for further details.


Call Javascript initialization function for your Rail controllers and views




No packages published


You can’t perform that action at this time.