Sha256: 2ab9f76bb765e8bede85b46ed96f2168bba0105cc1b6855315cacd6dfcf95e33
Contents?: true
Size: 1.98 KB
Versions: 5
Compression:
Stored size: 1.98 KB
Contents
module Qcourses class EventsController < BaseController resource '/events' get request_url do begin CourseRepository.all @events = Event.planned haml :'events/index', layout: false rescue Exception => e haml :'trainings/error', locals: { message: e.message } end end get admin_request_url do begin CourseRepository.all @events = Event.order(:from) haml :'events/admin_index', layout: :admin rescue Exception => e haml :'trainings/error', locals: { message: e.message } end end get admin_new_request_url do begin @event = Event.new @events = Event.order(:from) haml :'events/new', layout: :admin rescue Exception => e haml :'trainings/error', locals: { message: e.message } end end get admin_edit_request_url(:id) do begin @event = Event.find(params[:id]) haml :'events/edit', layout: :admin rescue Exception => e haml :'trainings/error', locals: { message: e.message } end end post admin_request_url do @event = Event.create(event_params) redirect admin_new_request_url end put admin_request_url(:id) do begin @event = Event.find(params[:id]) if @event.update event_params redirect admin_request_url else haml :'events/edit', layout: :admin end rescue Exception => e haml :'trainings/error', locals: { message: e.message } end end private def event_params @event_params ||= filter_event_params end def filter_event_params result = params[:event] valid_parameters = ["course_id", "from", "to", "location"] if (result[:location_id] && result[:location_id] != '0') valid_parameters << "location_id" valid_parameters.delete 'location' end result.select {|key| valid_parameters.include?(key)} end end end
Version data entries
5 entries across 5 versions & 1 rubygems