Class: EventsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- EventsController
- Defined in:
- app/controllers/events_controller.rb
Overview
This controller manage the Fact model
Instance Method Summary collapse
-
#filter_params ⇒ Object
private
Filter params for events search.
-
#index ⇒ Object
GET /events.
-
#show ⇒ Object
GET /events/:id.
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 events search
27 28 29 |
# File 'app/controllers/events_controller.rb', line 27 def filter_params params.fetch(:filter, {}).permit(:category, :from, :text, :to) end |
#index ⇒ Object
GET /events
8 9 10 11 12 13 14 15 |
# File 'app/controllers/events_controller.rb', line 8 def index @categories = Group.pluck :title, :id from = filter_params[:from] to = filter_params[:to] group_id = filter_params[:category] text = filter_params[:text] @pagy, @events = pagy(Event.searchable(from:, to:, group_id:, text:), items: 6) end |
#show ⇒ Object
GET /events/:id
18 19 20 21 22 |
# File 'app/controllers/events_controller.rb', line 18 def show @event = Event.find(params[:id]) @scope = @event.id redirect_to happening_path(@event.happenings.last) if @event.single == true end |