简体   繁体   中英

Rails form_tag No route matches

I have routes

  post '/request/:payment_system' => 'new_domain/accounts#withdraw_request', constraints: { payment_system: /webmoney|visa|mastercard|bank|qiwi|ym|neteller|skrill/ }

and form_tag

 form_tag({ action: :withdraw_request}) do

my controller action

class NewDomain::AccountsController < ApplicationController

    def withdraw_request
      some code here
    end
end 

but i have got

No route matches {:action=>"withdraw_request", :controller=>"new_domain/accounts"

How to fix it?

Assume you need a collection route,Puts this codes in your routes.rb:

 namespace :new_domain do
   resources :accounts, only: [] do
      collection do
        get :withdraw_request
      end
   end
 end

form_tag({ action: :withdraw_request}) do It will make post '/request/:payment_system' useless, where is the payment_system value and where is /request?

If you really want to make a POST request to withdraw_request, you need to make a collection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM