Last active
December 15, 2015 05:49
-
-
Save Viswanathantv/5212045 to your computer and use it in GitHub Desktop.
tv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
../controllers/rd_transactions.rb | |
def create | |
@rd_transaction = RdTransaction.new(params[:rd_transaction]) | |
@rd = Rd.find(params[:rd_id]) | |
@rd.update_attribute( :current_amount, (@rd.current_amount + @rd_transaction.amount_deposited)) | |
respond_to do |format| | |
if @rd_transaction.save | |
@rd.save | |
format.html { redirect_to @rd_transaction, notice: 'Rd transaction was successfully created.' } | |
format.json { render json: @rd_transaction, status: :created, location: @rd_transaction } | |
else | |
format.html { render action: "new" } | |
format.json { render json: @rd_transaction.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
../models/member.rb | |
class Member < ActiveRecord::Base | |
has_many :rd_transactions | |
has_many :rds , :through => :rd_transactions | |
end | |
../models/rd.rb | |
class Rd < ActiveRecord::Base | |
has_many :rd_transactions | |
has_many :members , :through => :rd_transactions | |
end | |
../models/rd_transactions.rb | |
class RdTransaction < ActiveRecord::Base | |
belongs_to :rd | |
belongs_to :member | |
validates_existence_of :rd | |
validates_existence_of :member | |
end | |
ActiveRecord::RecordNotFound in RdTransactionsController#create | |
Couldn't find Rd without an ID | |
Rails.root: /home/tv/Desktop/work/bank | |
Application Trace | Framework Trace | Full Trace | |
app/controllers/rd_transactions_controller.rb:48:in `create' | |
Request | |
Parameters: | |
{"utf8"=>"✓", | |
"authenticity_token"=>"EZ9qSaxZDiuUCWn4MQlNSnJPI+vFe9d1447fu2GMgv8=", | |
"rd_transaction"=>{"rd_id"=>"1", | |
"member_id"=>"1", | |
"amount_deposited"=>"333", | |
"deposit_type"=>"cash"}, | |
"commit"=>"Create Rd transaction"} | |
Show session dump | |
Show env dump | |
Response | |
Headers: | |
None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment