Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/getsimpleadmin/simple_crudify
The simple_crudify gem is a lightweight library for writing simple CRUD controllers.
https://github.com/getsimpleadmin/simple_crudify
crud-controllers ruby ruby-on-rails
Last synced: 6 days ago
JSON representation
The simple_crudify gem is a lightweight library for writing simple CRUD controllers.
- Host: GitHub
- URL: https://github.com/getsimpleadmin/simple_crudify
- Owner: getsimpleadmin
- Created: 2019-01-20T16:23:28.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-03T09:07:55.000Z (about 1 month ago)
- Last Synced: 2024-10-22T23:17:30.192Z (16 days ago)
- Topics: crud-controllers, ruby, ruby-on-rails
- Language: Ruby
- Homepage:
- Size: 18.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![Build Status](https://secure.travis-ci.org/getsimpleadmin/simple_crudify.svg?branch=master)](http://travis-ci.org/getsimpleadmin/simple_crudify)[![Gem Version](https://badge.fury.io/rb/simple_crudify.svg)](https://rubygems.org/gems/simple_crudify)
# SimpleCrudifyThe simple_crudify gem is a lightweight library for writing simple CRUD controllers.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'simple_crudify'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install simple_crudify
## Usage
A short example
```ruby
class UsersController < ApplicationController
include SimpleCrudify::Crudifyactions :crud
def model_klass
User
enddef controller_notice(action_name)
t("resource.#{action_name}.success", resource_name: model_klass)
endprivate
def after_create_path
edit_user_path(@resource)
enddef after_update_path
users_path
enddef after_destroy_path
users_path
enddef resource_params
params.require(:user).permit(:password, :phone, :email)
end
end
```### Controller configuration
The first required configuration is an action name.
```ruby
actions :index, :show, :new, :create
actions :crud # an alias for all actions
```Other settings
```ruby
def model_klass
User
end
```Allow specifying the model class.
```ruby
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](http://opensource.org/licenses/MIT).