Sha256: 9adc2b0e511421e91c5f249843ab37dd0514252f4cd2d98ba694377076b01830

Contents?: true

Size: 999 Bytes

Versions: 2

Compression:

Stored size: 999 Bytes

Contents

module Elabs
  class UsersController < ElabsApplicationController
    ALLOWED_ORDER_FROM = %w[username created_at].freeze
    DEFAULT_ORDER      = { username: :desc }.freeze

    before_action :set_user, only: %i[show edit update destroy]

    # GET /users
    # GET /users.json
    def index
      @users = User.page(params[:page]).per(self.class::MAX_ITEMS_PER_PAGE)
    end

    # GET /users/1
    # GET /users/1.json
    def show
      @user_albums   = @user.albums.for_relation
      @user_articles = @user.articles.for_relation
      @user_notes    = @user.notes.for_relation
      @user_projects = @user.projects.for_relation
      @user_uploads  = @user.uploads.for_relation
    end

    private

    # Use callbacks to share common setup or constraints between actions.
    def set_user
      @user = User.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def user_params
      params.fetch(:user, {})
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
elabs-2.0.0 app/controllers/elabs/users_controller.rb
elabs-2.0.0.pre app/controllers/elabs/users_controller.rb