简体   繁体   中英

Form submit using 'form_tag' and namespaces in Ruby on Rails-3

I am trying to call the 'update' method from 'ROOT_RAILS/controllers/users/account_controller.rb'

  ...
end

def update
  ...
end

def ...

using a "form_tag' in '/ROOT_RAILS/views/users/accounts/account.rb:

<% form_tag ( users_account_path, :method => :post ) do %>
  <%= text_field_tag :name %>
  <%= text_field_tag :surname %>
  <%= submit_tag_tag "Update" %>  
<% end %>

and having a namespace in 'ROOT_RAILS/config/routes.rb'

...
  namespace "users" do
    resources :accounts do
      collection do
        ...
      end
    end
  end
...

When I try to submit this form, I have a

No route matches "/users/accounts/2"

What am I wrong?


In 'form_tag' I tryed

:controller => "users/accounts", :action => "update"

instead of

users_account_path

that I think is the same.


If I use an ActiveRecord form works:

<%= form_for(@account, :url => { :action => "update", :controller => "accounts" } }) do |f| %>
  ...

你有没有尝试过:

users_accounts_path

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