Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8793477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:07:39+00:00 2026-06-13T23:07:39+00:00

I have just started using Rails and I am trying to build a banking

  • 0

I have just started using Rails and I am trying to build a banking app. I am having trouble setting up transactions between accounts.

I have currently scaffolded Transaction and Account. In my transaction page I can create a list of transaction with each transaction containing information about the source account, amount to transfer and the destination account. However, at the end of the page I would like a link or a button that processes all the transactions on the page and clears the page. Thus, modifying all the specified account balances.

Below is the steps I took in going about it.

1) In transaction model (transaction.rb model) define process method

class Transaction < ActiveRecord::Base
    def proc (transaction) 
        # Code processes transactions
        @account = Account.find(transaction.from_account)
        @account.balance = @account.balance - transaction.amount
        @account.update_attributes(params[:account]) #update the new balance
end
end

2) Then create a method in transaction controller call execute

def execute
      @transaction = Transaction.find(params[:id])
    proc (@transaction)
    @transaction.destroy

      respond_to do |format|
      format.html { redirect_to transactions_url }
      format.json { head :no_content }
  end

3) Then define the a link to display on the transaction page (shown below):

<% @transactions.each do |transaction| %>
  <tr>
    <td><%= transaction.from_account %></td>
    <td><%= transaction.amount %></td>
    <td><%= transaction.to_account %></td>
    <td><%= link_to 'Execute', transaction, confirm: 'Are you sure?', method: :execute %></td>
    <td><%= link_to 'Show', transaction %></td>
    <td><%= link_to 'Edit', edit_transaction_path(transaction) %></td>
    <td><%= link_to 'Destroy', transaction, confirm: 'Are you sure?', method: :delete %></td>
    <td><%= transaction.id%></td>
 </tr>
<% end %>

4) But when I click the Execute link I get the routing error:
[POST] “/transactions/6”

Currently my routes(routes.rb) are setup as follows:

resources :transactions do
       member do
       post :execute
       end
   end

  resources :accounts

How do I setup the routes so that it may process my method?
Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:07:40+00:00Added an answer on June 13, 2026 at 11:07 pm

    What you’re trying to do here is not add a new method, but a new ‘HTTP verb’. Don’t do it. You’ll likely receive a nasty message like this:

        !! Unexpected error while processing request: EXECUTE, accepted HTTP methods are OPTIONS,
     GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, 
    UNLOCK, VERSION-CONTROL, REPORT, CHECKOUT, CHECKIN, UNCHECKOUT, MKWORKSPACE, UPDATE, LABEL,
     MERGE, BASELINE-CONTROL, MKACTIVITY, ORDERPATCH, ACL, SEARCH, and PATCH
    

    In the console run ‘rake routes‘ and be sure you have the route for execute registered. Something like:

    execute_transaction
    

    Then update your execute link and replace ‘transaction’ with the proper path finder, and set the method to :post instead.

    link_to "Execute", execute_transaction_path(transaction), method: :post
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jruby rails app and I've just started using bundler for gem
I have just started learning Rails and I'm trying to build a post/like type
I just started using CakePHP for a small project. I have rails experience, and
I have just started out on rails and I've been using the mysql2 gem
I have just started coding with rails. I am using: Rails 3.2.8 ruby 1.9.3p194
I have just started considering using the HTML 5 api for a Rails/JQuery project,
I just started using Google Cloud Storage with a Rails 3 app. I am
I've just started using the brakeman gem to explore my rails app for security
I just started using rails, I have a model generated with a set of
Just started using carrierwave with Rails and things have been going smoothly with one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.