Class: Editor::HappeningsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ApplicationController
- Editor::HappeningsController
- Defined in:
- app/controllers/editor/happenings_controller.rb
Overview
This controller manafe Happening model for editors
Instance Method Summary collapse
-
#create ⇒ Object
POST /editor/happenings.
-
#destroy ⇒ Object
DELETE /editor/events/:event_id/happenings/:id.
-
#edit ⇒ Object
GET /editor/events/:event_id/happenings/:id/edit.
-
#index ⇒ Object
GET /editor/events/:event_id/happenings.
-
#new ⇒ Object
GET /editor/events/event_id/happenings/new.
-
#show ⇒ Object
GET /editor/events/:event_id/happenings/:id.
-
#update ⇒ Object
PATCH/PUT /editor/events/:event_id/happenings/:id.
Methods inherited from ApplicationController
#default_url_options, #new_session_path
Instance Method Details
#create ⇒ Object
POST /editor/happenings
50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/editor/happenings_controller.rb', line 50 def create @event = Event.find_by(id: massive_create_params[:event_id], group: @groups) @happenings = @event.happenings.massive_create(**massive_create_params.to_h.) @happening = @happenings.first if @happening.save render "editor/events/show" else render :new end end |
#destroy ⇒ Object
DELETE /editor/events/:event_id/happenings/:id
72 73 74 75 |
# File 'app/controllers/editor/happenings_controller.rb', line 72 def destroy @happening.destroy redirect_to editor_event_path(@happening.event) end |
#edit ⇒ Object
GET /editor/events/:event_id/happenings/:id/edit
45 46 47 |
# File 'app/controllers/editor/happenings_controller.rb', line 45 def edit @happening.questions.new end |
#index ⇒ Object
GET /editor/events/:event_id/happenings
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/editor/happenings_controller.rb', line 10 def index request.format = filter_params[:format].to_sym if filter_params[:format].present? @categories = Group.pluck :title, :id @scope = filter_params[:scope] from = filter_params[:from] to = filter_params[:to] event_id = filter_params[:scope] group_id = @groups.exists?(filter_params[:category]) ? filter_params[:category] : @groups.pluck(:id) text = filter_params[:text] soldout = filter_params[:soldout] searchable = Happening.searchable(from:, to:, event_id:, group_id:, text:, soldout:, reserved: true) respond_to do |format| format.html { @pagy, @happenings = pagy(searchable, items: 6) } format.csv { @happenings = searchable.includes(:questions, tickets: [ :answers, :user ]) } format.pdf { @happenings = searchable.includes(:questions, tickets: [ :answers, :user ]) } end end |
#new ⇒ Object
GET /editor/events/event_id/happenings/new
38 39 40 41 42 |
# File 'app/controllers/editor/happenings_controller.rb', line 38 def new @event = Event.find_by(id: params[:event_id], group: @groups) @happening = @event.happenings.new @templates = Template.pluck :title, :id end |
#show ⇒ Object
GET /editor/events/:event_id/happenings/:id
29 30 31 32 33 34 35 |
# File 'app/controllers/editor/happenings_controller.rb', line 29 def show respond_to do |format| format.html { } format.csv { } format.pdf { } end end |
#update ⇒ Object
PATCH/PUT /editor/events/:event_id/happenings/:id
63 64 65 66 67 68 69 |
# File 'app/controllers/editor/happenings_controller.rb', line 63 def update if @happening.update(happening_params) render action: :show else render :edit end end |