Rails generator to create a dynamic scaffold based on the Sammy JS framework.
JavaScript Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
generators/sammy_crud
lib
public
tasks
MIT-LICENSE
README.rdoc
Rakefile
init.rb
install.rb
uninstall.rb

README.rdoc

SammyCrud (Rails generator)

Sammy is a tiny javascript framework built on top of jQuery inspired by Ruby's Sinatra. github.com/quirkey/sammy

SammyCrud is a Rails generator that creates a dynamic version of the basic scaffold (using Sammy & Ajax). All your CRUD (Create-Read-Update-Delete) operations will happen on the same page. It is for example very useful for quick admin interfaces.

Quick start

  • $ rails sammyonrails

  • $ ./script/plugin install git://github.com/ahe/sammy_crud.git

  • $ ./script/generate model article title:string author:string

  • $ rake db:migrate

  • $ ./script/generate sammy_crud article

Insert the Javascript includes into your layout :

<%= javascript_include_tag 'sammy/jquery-1.3.2.min' %>
<%= javascript_include_tag 'sammy/jquery-ui-1.7.2.custom.min' %>  
<%= javascript_include_tag 'sammy/sammy' %>
<%= javascript_include_tag 'sammy/sammy_crud' %>
  • $ ./script/server

Launch localhost:3000/articles

HAML

If you prefer Haml, this command is for you :

$ ./script/generate sammy_crud article haml

MongoMapper

SammyCrud is now compatible with MongoMapper!

Override default behaviors

If you want to customize one of the action, you can easily rewrite it :

<script type="text/javascript">
  $(function() {
    var app = newSammyApp();

    app.route('get', '#/show/:id', function() { with(this) {
      alert('#/show/:id has been redefined!');
    }});

    addCRUDRoutes(app, 'articles');
    app.run();
  });
</script>

Prefix your URLs

You can simply add a prefix to your URLs like this :

addCRUDRoutes(app, 'articles', 'my_prefix/');

Copyright © 2009 Anthony Heukmes, released under the MIT license.