0.0
No commit activity in last 3 years
No release in over 3 years
EasyController is a contrller plugin which help you write less code in common controllers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.7
~> 10.0
 Project Readme

EasyController

EasyController is a controller plugin which help you write less code in common controllers

Installation

Add this line to your application's Gemfile:

gem 'easy_controller'

And then execute:

$ bundle

Or install it yourself as:

$ gem install easy_controller

Usage

Before use easy_controller we have to write controller code like this:

class UsersController < ApplicationController

  before_action :find_user, only: [:show, :edit, :update, :destroy]

  def show
  
  end

  def create
    @user = User.create(user_params)
  end


  protected
  
  def find_user
    @user = User.find(params[:id])
  end
  
   def user_params
    params.require(:user).permit(:name, :email)
  end

end

Use easy_controller we can write code with less work:

class UsersController < ApplicationController

  easy_controller model: :user, permit: [:name,:email]

  def show
  
  end

  def create
    user = User.create(user_params)
  end

end

The easy_controller method would automatically generate find_user, user_params functions, and invoke before_action :find_user, only: [:show, :edit, :update, :destroy] in the controller