Sunday, April 13, 2008


The rails plugin spakit means Single Page Application KIT. It can transform rails app into single page app but not modify app structure in large scale by loading content of other controller into primary controller.

The installation step is from
$ sudo gem install spakit
$ cd railsapp/vendor/plugins/
$ gem unpack spakit
$ mv spakit-version spakit

now installation finished.

Before using it, spakit need a layout railsapp/app/view/layout/spakit.rhtml<%= flash[:notice] %>
<%= yield %>

And the layout application.rhtml should contain
<%= javascript_include_tag :defaults %> to include default js file.

Now we can use it happy. Add <div id="content"></div> into the view of primary controller, and set a spakit link: <%= spakit_link_to 'new person', :url => new_person_path %>, the content of the url will appear in the div#content.

Also two other helpers contain in spakit, spakit_form_for and spakit_form_tag

link1: spakit at rubyforge
link2: spakit at github

No comments: