Defined an action transfer in transactions controller (Rails 4.2). Action transfer is similar to new by bringing up a form transfer.html.erb for user to fill and save:
def transfer
@title = t('Account Transfer')
@transaction = BankAccountx::Transaction.new()
end
In routes.rb, define the route:
resources :transactions do
member do
get :transfer
patch :transfer_result
end
end
Here is the spec:
it "should render transfer" do
session[:user_id] = @u.id
get 'transfer'
expect(response).to be_success
end
In rspec, there is error:
ActionController::UrlGenerationError:
No route matches {:action=>"transfer", :controller=>"bank_accountx/transactions"}
The following is in the spec:
routes {BankAccountx::Engine.routes}
If we use collection instead of member in routes.rb, then the above rspec passes. The following route works:
resources :transactions do
collection do
get :transfer
patch :transfer_result
end
end
Why this member action transfer requires collection route in routes.rb?