When I run my transaction, it doesn't throw my errors partial displaying that amount can't be string characters, they have to be integers. Not sure why this is the case, any ideas? My errors works on my other controllers, but on my transaction code.
Code:Payments Controller def create @debt = current_user.debts.find params[:debt_id] @payment = @debt.payments.build params[:payment] @payment.user_id = current_user.id if @payment.save_and_update(@debt) redirect_to @debt else render 'debts/show' end endCode:Payment Model attr_accessible :amount validates :amount, presence: true, :numericality => true belongs_to :debt def save_and_update(debt) self.transaction do self.save debt.update_attributes(amount: debt.amount - self.amount) end endCode:Routes resources :debts do resources :payments end


Reply With Quote

Bookmarks