3. Model
●
Use 'scope'
scope :admin, ->{where(admin: true)}
●
Use 'module'
app/model/concern/set_user.rb
module SetUser
//code goes here
end
app/model/user.rb
class Admin < ActiveRecord::Base
include SetUser
5. Controller
Use respond_with and respond_to
class UsersController <
ApplicationController
respond_to :html, :json, :xml
def index
@users = User.all
respond_with @users
end
6. Controller
●
Move business code logic into model methods.
●
Move view logic code into helper methods.
And then try to DRY it up.