Beautiful controller in Ruby on Rails
Your controllers is too fat and messy. You want to make them better. You should be follow these rules: Short, DRY, easy to read Minimum amount of glue code between request and model Unless there is good reason, controller should be follow a standard When user’s interactions are normalized to CRUD. Our controller could be like this class ObjectController < ApplicationController def index load_objects end def show load_object end def new build_object end def create build_object save or render 'new' end def edit load_object build_object end def update load_object build_object save or render 'edit' end def destroy load_object @object . destroy redirect_to objects_path end private def object_params obj_params = params [ :object ] obj_params ? obj_params . permit ( :id , :attributes ) : {} end def loa