Files
mapknitter/app/controllers/users_controller.rb
Cess a671852964 Upgrade from Rails 3.2 to Rails4.2 (#578)
* Configurations update for rails 4.0

* ActiveSupport::Testing::Performance extracted to a gem

* ruby prof required as a dependency

* disable rubocop on bin folder

* http patch

* Comment out to allow testing

* no longer supports plugin loading

* lock to sprockets 2.12

* Active record patches

* remove deprecated test syntax

* fix failing tests

* change new super class

* replace right_aws with right_aws_api

right_aws is no longer maintained, was throwing an error

* Change test lib to minitest, add  minitest reporters

* lock to rails 4.2.11.1

* change rails version in install script

* remove deprecation warnings

* make app work

* active record find patches

* root_in_json include defaulted to false

* confirm option removed in link helper

* cookies serializer changed to hybrid

* Change render :text to :plain

render :text will be deprecated and poses a security risk

* console for dev web

* Check and fix interface functionality

* fix export functionality

* add protected attributes for the warpable model

* fix image upload

* Fix comments and images failing tests

* include mass assignment security in annotations

* render html for update images

* clear mail array before every test

* Fix codeclimate issues

* skip failing test

The test is failing because of different names in model(warpable) and
controller(images) skipping this for now until we decide if we want to
standardize the names

* replace unprotected redirects

* fix fa icons

* fix login functionality

* precompile images

* fix codeclimate issues

* Fix oauth icons
2019-06-13 16:58:59 -04:00

36 lines
928 B
Ruby

class UsersController < ApplicationController
helper_method :sort_column, :sort_direction
def profile
params[:id] = current_user.login if logged_in? && params[:id].empty?
@user = User.find_by_login(params[:id])
@maps = Map.where(user_id: @user.id)
.paginate(page: params[:page], per_page: 24)
end
def index
@title = 'Prolific map authors'
@users = User.joins(:maps)
.select('users.*, count(users.id) as maps_count')
.group('maps.user_id')
.order(sort_column + ' ' + sort_direction)
.paginate(page: params[:page], per_page: 24)
render 'users/index'
end
private
def sort_column
params[:sort] || 'maps_count'
end
def sort_direction
params[:direction] || 'desc'
end
def user_params
params.require(:user).permit(:login, :email, :name,
:password, :password_confirmation)
end
end