Class: Event::API::V2::Admin::EventsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- Event::ApplicationController
- BaseController
- Event::API::V2::Admin::EventsController
- Defined in:
- app/controllers/event/api/v2/admin/events_controller.rb
Constant Summary
Constants inherited from BaseController
Instance Method Summary collapse
-
#create ⇒ Object
POST /admin/events.
-
#history ⇒ Object
GET admin/events/history.
-
#index ⇒ Object
GET /admin/events.
-
#show ⇒ Object
GET /admin/events/:id.
-
#update ⇒ Object
PUT /admin/events/:id.
Methods inherited from BaseController
Methods included from JWTPayload
#email, #jwt_payload, #role, #uid
Methods included from ExceptionHandlers
Methods included from Response
#controller_namespace, #error_response, #errors_response, #json_response, #not_found
Instance Method Details
#create ⇒ Object
POST /admin/events
26 27 28 29 30 31 32 33 |
# File 'app/controllers/event/api/v2/admin/events_controller.rb', line 26 def create event = nil ActiveRecord::Base.transaction do event =Event.create!(events_params) end json_response(event, 201) end |
#history ⇒ Object
GET admin/events/history
36 37 38 39 40 |
# File 'app/controllers/event/api/v2/admin/events_controller.rb', line 36 def history event = Event.find(params[:event_id]) json_response(event.participants, 201) end |
#index ⇒ Object
GET /admin/events
9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/event/api/v2/admin/events_controller.rb', line 9 def index ransack_params = { state_in: params[:state], currency_id_eq: params[:currency_id], name_cont_all: params[:name] } sales = Event.ransack(ransack_params) json_response(paginate(sales.result), 200) end |
#show ⇒ Object
GET /admin/events/:id
21 22 23 |
# File 'app/controllers/event/api/v2/admin/events_controller.rb', line 21 def show json_response(Event.find(params[:id]), 200) end |
#update ⇒ Object
PUT /admin/events/:id
43 44 45 46 47 48 |
# File 'app/controllers/event/api/v2/admin/events_controller.rb', line 43 def update event = Event.find(params[:id]) event.update!(events_params) json_response(event, 200) end |