I have method inside AplicationController which I want to be reusable from all controllers:
class AplicationController < ActionController::Base
protected
def set_cartridge_values(cartridge, cartridge_value, param_value)
@quantity = cartridge.cartridge_value.to_i + param_value.to_i
cartridge.update(cartridge_value: @quantity)
end
I in some controller I want to cal this method like that:
set_cartridge_values(@cartridge, ? ,params[:toner_kg][:weight])
In place of ? mark I dont know how to pass that parameter.
@cartridge - is a varaible defined before
params[:toner_kg][:weight] - is a value
and cartridge_value - is a attribute of a cartridge.
For example I want to pass toner_gr attribute of a cartridge model and update that attribute.