Improved event creation, to handle params like event[tag_list]=test

This commit is contained in:
echarp 2018-03-02 10:23:16 +01:00
parent fa3b63d237
commit 980d6421aa

View File

@ -6,7 +6,7 @@ class EventsController < ApplicationController
before_action :set_events, only: [:index]
before_action :set_event, except: %i[index new preview_create create]
before_action :set_create_event, only: %i[preview_create create]
before_action :set_create_event, only: %i[new preview_create create]
before_action :check_secret, only: %i[edit preview update destroy]
before_action :set_mailer_host
rescue_from ActiveRecord::StaleObjectError, with: :locked
@ -22,13 +22,7 @@ class EventsController < ApplicationController
end
# GET /events/new
def new
time = Time.zone.now.change(min: 0) + 1.day
@event = Event.new start_time: time,
end_time: time + 1.hour,
region_id: session[:region],
tag_list: params[:tag_list]
end
def new; end
# POST /events/preview
def preview_create
@ -101,6 +95,12 @@ class EventsController < ApplicationController
end
def set_create_event
time = Time.zone.now.change(min: 0) + 1.day
params[:event] ||= {
start_time: time,
end_time: time + 1.hour,
region_id: session[:region]
}
@event = Event.new event_params
end