Lazy way to implement common actions in controllers in Rails

docs Gem Version Build Status Code Climate Test Coverage Dependency Status


  • Minimal Controller Coding
  • Resource Can be Scoped to Parent Resource


  • Generic Error Handeling
  • i18n
  • lambdas and procs for inserting custom behavior



gem 'lazy_crud'


gem install lazy_crud


Basic setup

class SomeObjectController < ApplicationController
  include LazyCrud

  # At a bare minimum, you'll need to specify the
  # class the controller is acting upon.
  set_resource SomeObject

  # optional
  # this is for in the case of you having nested routes, and want to scope
  # SomeObject to its parent object.
  # For example: /event/:event_id/discounts/:id
  # Event is the parent object and Discount is the resource
  # Note that there must be an @event instance variable set
  # See specs for details
  set_resource_parent Event

  # sort of optional
  # if you want to be able to update / create objects, you'll want to
  # specify what parameters are allowed to be set.
  # this uses strong parameters
  set_param_whitelist(:name, :amount)


  1. Fork the project
  2. Create a new, descriptively named branch
  3. Add Test(s)!
  4. Commit your proposed changes
  5. Submit a pull request