I have a Bank model with attributes id, name, code and rate. I just changed the rate method of bank model. But the problem is when I am updating the bank objects, it considers the condition in the rate attribute method. I want to update the original value whatever I am getting from the inputs.
Ref attribute of Bank model
def rate
authorised? ? (super * 100) : 0
end
Update method in banks controller
def update_banks
banks = []
banks = get_all_banks(params[:banks])
begin
ActiveRecord::Base.transaction do
if banks.each { |b| b.save! }
redirect_to banks_url, notice: 'Banks were successfully updated.'
else
raise ActiveRecord::Rollback
end
end
rescue Exception=>e
redirect_to edit_rates_rates_path(bank_id: params.fetch(:select_bank)[:bank_id], product_id: params.fetch(:select_product)[:product_id], date: params[:date])
flash[:error] = ["<b>Rates could not be updated at the moment.</b>"]
rates.each { |rate| rate.errors.full_messages.each { |message| flash[:error] << message } }
end
end
I am getting list of bank objects. Is there any way to tell rails to ignore "rate" method of bank model and consider the input value?
Thanks