The simple_crudify gem is a lightweight library for writing simple CRUD controllers.
Add this line to your application's Gemfile:
gem 'simple_crudify'
And then execute:
$ bundle
Or install it yourself as:
$ gem install simple_crudify
A short example
class UsersController < ApplicationController
include SimpleCrudify::Crudify
actions :crud
def model_klass
User
end
def controller_notice(action_name)
t("resource.#{action_name}.success", resource_name: model_klass)
end
private
def after_create_path
edit_user_path(@resource)
end
def after_update_path
users_path
end
def after_destroy_path
users_path
end
def resource_params
params.require(:user).permit(:password, :phone, :email)
end
end
The first required configuration is an action name.
actions :index, :show, :new, :create
actions :crud # an alias for all actions
Other settings
def model_klass
User
end
Allow specifying the model class.
def controller_notice(action_name)
t("resource.#{action_name}.success", resource_name: model_klass)
end
Helps to simplify controller redirect notice
Bug reports and pull requests are welcome on GitHub at https://github.com/getsimpleadmin/simple_crudify. This project is intended to be a safe, welcoming space for collaboration.
The gem is available as open source under the terms of the MIT License.