Improved event creation, to handle params like event[tag_list]=test
This commit is contained in:
parent
fa3b63d237
commit
980d6421aa
@ -6,7 +6,7 @@ class EventsController < ApplicationController
|
|||||||
|
|
||||||
before_action :set_events, only: [:index]
|
before_action :set_events, only: [:index]
|
||||||
before_action :set_event, except: %i[index new preview_create create]
|
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 :check_secret, only: %i[edit preview update destroy]
|
||||||
before_action :set_mailer_host
|
before_action :set_mailer_host
|
||||||
rescue_from ActiveRecord::StaleObjectError, with: :locked
|
rescue_from ActiveRecord::StaleObjectError, with: :locked
|
||||||
@ -22,13 +22,7 @@ class EventsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
# GET /events/new
|
# GET /events/new
|
||||||
def new
|
def new; end
|
||||||
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
|
|
||||||
|
|
||||||
# POST /events/preview
|
# POST /events/preview
|
||||||
def preview_create
|
def preview_create
|
||||||
@ -101,6 +95,12 @@ class EventsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_create_event
|
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
|
@event = Event.new event_params
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user