Routing form submission to a different controller

后端 未结 1 2000
-上瘾入骨i
-上瘾入骨i 2021-01-13 13:41

How do I specify the Controller and Action in a form submission? I am trying to use a \'Clients\' Controller to create an Account and an associated Person (\'Client\').

相关标签:
1条回答
  • 2021-01-13 14:05

    You have to say this in routes.rb

    resources :clients
    

    In the form, specify the url as clients_path with method as post:

    <%= form_for @account, :url => clients_path, :html => {:method => :post} do |f| %>
     ---
    <% end
    

    For more information how rails handles REST urls: http://microformats.org/wiki/rest/urls

    0 讨论(0)
提交回复
热议问题