Skip to content

The simple_crudify gem is a lightweight library for writing simple CRUD controllers.

Notifications You must be signed in to change notification settings

getsimpleadmin/simple_crudify

Repository files navigation

Build StatusGem Version

SimpleCrudify

The simple_crudify gem is a lightweight library for writing simple CRUD controllers.

Installation

Add this line to your application's Gemfile:

gem 'simple_crudify'

And then execute:

$ bundle

Or install it yourself as:

$ gem install simple_crudify

Usage

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

Controller configuration

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

Contributing

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.

License

The gem is available as open source under the terms of the MIT License.

About

The simple_crudify gem is a lightweight library for writing simple CRUD controllers.

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published