Class: HappeningsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/happenings_controller.rb

Overview

this controller manage the User views for Happening model.

Instance Method Summary collapse

Methods inherited from ApplicationController

#access_denied!, #default_url_options, #record_not_found!, #set_turbo, #switch_locale

Instance Method Details

#filter_paramsObject (private)

filter params for search Happening



28
29
30
# File 'app/controllers/happenings_controller.rb', line 28

def filter_params
  params.fetch(:filter, {}).permit(:category, :from, :scope, :text, :to)
end

#indexObject

GET /event/:event_id/happenings show a paginate list of Happening



7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/happenings_controller.rb', line 7

def index
  @categories = Group.pluck :title, :id
  @scope   = filter_params[:scope]
  from     = filter_params[:from]
  to       = filter_params[:to]
  event_id = filter_params[:scope]
  group_id = filter_params[:category]
  text     = filter_params[:text]
  @pagy, @happenings = pagy(Happening.searchable(from:, to:, event_id:, group_id:, text:), items: 6)
end

#showObject

GET /event/:event_id/happenings/:id Show detail of happening and a form to prenotate a ticket



20
21
22
23
# File 'app/controllers/happenings_controller.rb', line 20

def show
  @happening = Happening.includes(:event).find(params[:id])
  @event = @happening.event
end