开发者

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

开发者 https://www.devze.com 2023-02-03 15:48 出处:网络
I am trying to call the \'update\' method from \'ROOT_RAILS/controllers/users/account_controller.rb\'

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:

<%= f开发者_开发知识库orm_for(@account, :url => { :action => "update", :controller => "accounts" } }) do |f| %>
  ...


Have you tried:

users_accounts_path
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号