Class: Api::NetworksController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- Api::NetworksController
- Defined in:
- app/controllers/api/networks_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
-
#index ⇒ Object
before_action :sanitize, only: [:create, :update].
- #show ⇒ Object
Methods included from Response
Instance Method Details
#create ⇒ Object
28 29 30 31 |
# File 'app/controllers/api/networks_controller.rb', line 28 def create NetworkCsvMakerWorker.perform_async render json: { data: 'The network is being created... please check back on the API' }, status: :ok end |
#destroy ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/controllers/api/networks_controller.rb', line 33 def destroy if @network.destroy render json: { data: 'The network has been deleted' }, status: :ok else render json: { data: 'Something went wrong' }, status: :unprocessable_entity end end |
#index ⇒ Object
before_action :sanitize, only: [:create, :update]
13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/api/networks_controller.rb', line 13 def index networks = Network.all.map do |network| { id: network.id, created_at: network.created_at, updated_at: network.updated_at } end json_response(networks) end |
#show ⇒ Object
24 25 26 |
# File 'app/controllers/api/networks_controller.rb', line 24 def show render json: @network, serializer: Api::NetworkSerializer end |