Skip to content

Commit

Permalink
Adds User#for_render
Browse files Browse the repository at this point in the history
  • Loading branch information
kikito committed Aug 26, 2015
1 parent 48ef4df commit b9634cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/controllers/admin/officials_controller.rb
@@ -1,11 +1,11 @@
class Admin::OfficialsController < Admin::BaseController

def index
@officials = User.officials.page(params[:page])
@officials = User.officials.page(params[:page]).for_render
end

def search
@users = User.with_email(params[:email]).page(params[:page])
@users = User.with_email(params[:email]).page(params[:page]).for_render
end

def edit
Expand All @@ -29,4 +29,4 @@ def user_params
params.require(:user).permit(:official_position, :official_level)
end

end
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Expand Up @@ -25,11 +25,11 @@ class User < ActiveRecord::Base

accepts_nested_attributes_for :organization

default_scope { includes(:organization) }
scope :administrators, -> { joins(:administrators) }
scope :moderators, -> { joins(:moderator) }
scope :organizations, -> { joins(:organization) }
scope :officials, -> { where("official_level > 0") }
scope :for_render, -> { includes(:organization) }

def self.find_for_oauth(auth, signed_in_resource = nil)
# Get the identity and user if they exist
Expand Down

0 comments on commit b9634cf

Please sign in to comment.