Sha256: 9229d0756d56a08987359000b82965187f41eb4511418f83d89e89d2685bef87
Contents?: true
Size: 1.48 KB
Versions: 9
Compression:
Stored size: 1.48 KB
Contents
module Logistics module Core class CurrencyRatesController < ApplicationController before_action :set_currency, only: [:update] def rates currency = Currency.find(params[:id]) rates = currency.currency_rates.order('rate_date DESC') response = Mks::Common::MethodResponse.new(true, nil, rates, nil, nil) render json: response end def create rate = CurrencyRate.new rate_params if rate.save response = Mks::Common::MethodResponse.new(true, 'Currency rate saved successfully!', nil, nil, nil) render json: response else errors = Mks::Common::Util.error_messages rate, 'Currency rate' response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) render json: response end end def update if @rate.update(rate_params) response = Mks::Common::MethodResponse.new(true, 'Currency rate updated successfully!', nil, nil, nil) render json: response else errors = Mks::Common::Util.error_messages @rate, 'Currency rate' response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil) render json: response end end private def set_currency @rate = CurrencyRate.find(params[:id]) end def rate_params params.require(:rate).permit(:currency_id, :rate_to_base_buying, :rate_to_base_selling, :rate_date) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems