Class: Editor::UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ApplicationController
- Editor::UsersController
- Defined in:
- app/controllers/editor/users_controller.rb
Overview
This controller manage User model for editors
Instance Method Summary collapse
-
#filter_params ⇒ Object
private
Filter params for search a Event.
-
#index ⇒ Object
GET /editor/users.
-
#list ⇒ Object
GET /editor/users/list.
-
#set_user ⇒ Object
private
Set @user for some method.
-
#show ⇒ Object
GET /editor/users/:id.
-
#tickets ⇒ Object
GET /editor/users/:id/tickets.
Methods inherited from ApplicationController
Methods inherited from ApplicationController
#access_denied!, #default_url_options, #record_not_found!, #set_turbo, #switch_locale
Instance Method Details
#filter_params ⇒ Object (private)
Filter params for search a Event
51 52 53 |
# File 'app/controllers/editor/users_controller.rb', line 51 def filter_params params.fetch(:filter, {}).permit(:text, :admin, :editor) end |
#index ⇒ Object
GET /editor/users
8 9 10 11 12 13 14 |
# File 'app/controllers/editor/users_controller.rb', line 8 def index if filter_params[:text].present? @text = [ "email ilike :text or email ilike :text", { text: "%#{filter_params[:text]}%" } ] end @pagy, @users = pagy User.where(@text) end |
#list ⇒ Object
GET /editor/users/list
17 18 19 20 21 22 23 |
# File 'app/controllers/editor/users_controller.rb', line 17 def list if filter_params[:text].present? @text = [ "email ilike :text or email ilike :text", { text: "%#{filter_params[:text]}%" } ] end @pagy, @users = pagy(User.where(@text).where()) end |
#set_user ⇒ Object (private)
Set @user for some method
46 47 48 |
# File 'app/controllers/editor/users_controller.rb', line 46 def set_user @user = User.find(params[:id]) end |
#show ⇒ Object
GET /editor/users/:id
26 27 28 |
# File 'app/controllers/editor/users_controller.rb', line 26 def show @categories = [ [ @user.email, @user.id ] ] end |
#tickets ⇒ Object
GET /editor/users/:id/tickets
31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/editor/users_controller.rb', line 31 def tickets @text = [ "events.title ilike :string", { string: "%#{filter_params[:text]}%" } ] if filter_params[:text].present? if current_user.admin? @pagy, @tickets = pagy(@user.tickets.joins(happening: [ :event ]).where(@text), items: 6) else @pagy, @tickets = pagy( @user.tickets.joins(happening: [ :event ]).where(happening: { event: @current_user.events }).where(@text), items: 6 ) end end |