Commits

Allan Davis committed 91b54f7

Got transactions working from accounts

Comments (0)

Files changed (4)

code/dragon_hoard/app/controllers/transactions_controller.rb

 
     respond_to do |format|
       if @transaction.save
-        format.html { redirect_to @transaction, notice: 'Transaction was successfully created.' }
+        format.html { redirect_to account_transaction_url(@account, @transaction), notice: 'Transaction was successfully created.' }
         format.json { render json: @transaction, status: :created, location: @transaction }
       else
         format.html { render action: "new" }
 
     respond_to do |format|
       if @transaction.update_attributes(params[:transaction])
-        format.html { redirect_to @transaction, notice: 'Transaction was successfully updated.' }
+        format.html { redirect_to account_transaction_url(@account, @transaction), notice: 'Transaction was successfully updated.' }
         format.json { head :no_content }
       else
         format.html { render action: "edit" }
     @transaction.destroy
 
     respond_to do |format|
-      format.html { redirect_to transactions_url }
+      format.html { redirect_to account_transactions_url(@account) }
       format.json { head :no_content }
     end
   end

code/dragon_hoard/app/views/transactions/_form.html.erb

-<%= form_for(@transaction, :action => account_transactions_path(@account.id), :method => :post) do |f| %>
+<%= form_for(@transaction, :url => url) do |f| %>
   <% if @transaction.errors.any? %>
     <div id="error_explanation">
       <h2><%= pluralize(@transaction.errors.count, "error") %> prohibited this transaction from being saved:</h2>
   <div class="actions">
     <%= f.submit %>
   </div>
-<% end %>
+<% end %>

code/dragon_hoard/app/views/transactions/edit.html.erb

 <h1>Editing transaction</h1>
 
-<%= render 'form' %>
+<%= render 'form', :url => account_transaction_path(@account, @transaction) %>
 
-<%= link_to 'Show', account_transaction_path @account, @transaction %> |
-<%= link_to 'Back', account_transactions_path @account %>
+<%= link_to 'Show', account_transaction_path(@account, @transaction) %> |
+<%= link_to 'Back', account_transactions_path(@account) %>

code/dragon_hoard/app/views/transactions/new.html.erb

 <h1>New transaction</h1>
 
-<%= render 'form' %>
+<%= render 'form', :url => account_transactions_path(@account.id) %>
 
 <%= link_to 'Back', account_transactions_path(@account) %>