class CompaniesController < ApplicationController

 before_filter :authenticate_user!, except: [:index, :show]
 before_action :only_admins, except: [:index, :show]

 def only_admins
  redirect_to companies_path, :alert => 'Only admin' unless current_user.admin
 end

end

Add a code snippet to your website: www.paste.org