No commit activity in last 3 years
No release in over 3 years
Provides default CRUD actions for a Rails controller.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.8.0
>= 1.2.3
 Project Readme

rails-crud_actions¶ ↑

DESCRIPTION¶ ↑

Provides default CRUD actions for a Rails controller.

FEATURES/PROBLEMS¶ ↑

  • Provides default CRUD actions for a Rails controller.

  • Simply include the module, for simpler debugging.

  • Allows overriding the actions.

  • Provides the 7 CRUD actions provided by Rails scaffolding/resources, plus ‘delete’.

    • Delete displays a page confirming that the user wants to delete an item.

SYNOPSIS¶ ↑

class UsersController < ApplicationController
  include BoochTek::Rails::CrudActions
  crud_model Person       # OPTIONAL: would have defaulted to User for the UsersController.
  crud_scope :conditions => {:name => 'Bill'}

  def index
    # Can provide an overrided version of an action.
  end
  after_filter :only => :show do
    # Can extend the functionality of the default version of an action. Can also use before_filter or around_filter.
  end
end

OR

class UsersController < ApplicationController
  crud_actions :model => Person, :conditions => {:name => 'Bill'}

  def index
    # Can provide an overrided version of an action.
  end
  after_filter :only => :show do
    # Can extend the functionality of the default version of an action. Can also use before_filter or around_filter.
  end
end

You should set your routes up like this, so that your delete actions are at users/1/delete instead of users/delete/1:

map.resources :users, :member => { :delete => :get }

REQUIREMENTS¶ ↑

  • Rails (actually, ActionController)

    • Will probably work with any version of Rails, but I’ve tested with Rails 2.2 and above.

INSTALL¶ ↑

script/plugin install git://github.com/boochtek/rails-crud_actions.git

ALTERNATIVES¶ ↑

* resource_controller - I didn't like their DSL, which seems more magical than this implementation.
* josevalim-inherited_resources - Looks OK, but hard to override actions, and has to be included via inheritance.
  * Uses 'resource' where I use 'item'; claims other "resourceful plugins" probably do as well.

LICENSE¶ ↑

(The MIT License)

Copyright © 2009 BoochTek, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.