Simulates RESTful with multiple submit buttons and no javascript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Rack RESTful Submit

Implements support of RESTful resources with Rails MVC when Javascript is off and bulk operations are required with multiple submit buttons.

Rack Builder

require 'rack-restful_submit'
use Rack::RestfulSubmit

Rails integration

Install GEM without Bundler

Insert into config/environment.rb:

config.gem "rack-restful_submit"


rake gems:install

Install GEM with Bundler

Insert into Gemfile:

gem "rack-restful_submit"


bundle install


We need to swap our RestfulSubmit middleware with MethodOverride which we don't need anymore.

Insert into config/environment.rb:

config.middleware.swap Rack::MethodOverride, 'Rack::RestfulSubmit'


In the example below you can see that using submit input with __rewrite name and multi_destroy mapping allows us to convert normal POST request into RESTful one. Don't forget to also insert 2 hidden fields URL and METHOD as shown below. NOTE: I'm aware of that adding collection to RESTfull controller ins't very RESTfull but this is only example of this GEM. If you want fully RESTfull create new controller for the bulk operations.

Example of industries/index.html.erb

<h1>Listing industries</h1>

<form method="post">

<% @industries.each do |industry| %>
    <td><%=h check_box_tag 'industry_ids[]', %></td>
    <td><%=h link_to, industry %></td>
    <td><%=h industry.description %></td>
    <td><%= link_to 'Edit', edit_industry_path(industry) %></td>
<% end %>

<input type="hidden" name="__map[multi_destroy][url]" value="<%= destroy_multiple_industries_url %>" />
<input type="hidden" name="__map[multi_destroy][method]" value="DELETE" />
<input type="submit" name="__rewrite[multi_destroy]" value="Destroy">


<br />

<%= link_to 'New industry', new_industry_path %>


map.resources :industries, :collection => { :destroy_multiple => :delete }


The Github way: Fork Me, Hack Me, Push Me, Send Me as Pull Request


(c) 2010 Ladislav Martincik - MIT License (see LICENSE)


1.2.2 - Relaxed GEM dependecies (Thanks to Vit Vondruch)
1.2.0 - Improvements & Optimalizations for Rails 3 (Thanks to J.Provaznik, F.Vollero)
1.1.2 - Fixing bug with double Rack call()
1.1.1 - Define Gemfile and decrease RSpec version to 1.3.0
1.1.0 - Version with MethodOverride support inside
1.0.0 - First working version