Class: Mks::Rent::ClientsController
- Inherits:
-
ApplicationController
- Object
- Auth::ApplicationController
- ApplicationController
- Mks::Rent::ClientsController
- Defined in:
- app/controllers/mks/rent/clients_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/mks/rent/clients_controller.rb', line 20 def create client = Client.new(client_params) if client.save render json: Mks::Common::MethodResponse.success_response(@client, 'Client created successfully!'), status: :created, location: client else response = Mks::Common::MethodResponse.failure_response(client) render json: response, status: :unprocessable_entity end end |
#filter ⇒ Object
14 15 16 17 18 |
# File 'app/controllers/mks/rent/clients_controller.rb', line 14 def filter search = "%#{params[:search].downcase}%" equipments = Client.where('lower(name) LIKE ?', search) render json: ApplicationRecord.as_json(equipments) end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/mks/rent/clients_controller.rb', line 6 def index render json: Mks::Common::MethodResponse.success_response(Client.all) end |
#show ⇒ Object
10 11 12 |
# File 'app/controllers/mks/rent/clients_controller.rb', line 10 def show render json: Mks::Common::MethodResponse.success_response(@client) end |
#update ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/controllers/mks/rent/clients_controller.rb', line 31 def update if @client.update(client_params) render json: Mks::Common::MethodResponse.success_response(@client, 'Client updated successfully!') else render json: Mks::Common::MethodResponse.failure_response(@client), status: :unprocessable_entity end end |