2011-07-05 17 views
0

我最近創建了一個新的rails 3應用程序,使用我爲Rails 2編寫的代碼,同時升級它以匹配新的API。rails 3未定義方法`_index_path'使用form_for時

我有以下代碼:

#routes.rb: 
FtpMgmt::Application.routes.draw do 
    resources :accounts 
    root :to => "accounts#index" 
    match ':controller(/:action(/:id(.:format)))' 
end 

#new.html.erb 
<% form_for(@account) do |f| %> 
... 
<% end %> 

#accounts_controller.rb 
class AccountsController < ApplicationController 
    respond_to :html, :xml, :json 
    def new 
     @account = Accounts.new 
     respond_with(@account) 
    end 
end 

我得到的錯誤是:

Showing /opt/rails/ftp_mgmt/app/views/accounts/new.html.erb where line #3 raised: 
undefined method `accounts_index_path' for #<#<Class:0x0000000a28a758>:0x0000000a269b70> 

你有什麼想法,我怎麼能解決這個問題?

回答

1
@account = Accounts.new 

應該

@account = Account.new 

而且

<% form_for(@account) do |f| %> 

應該

<%= form_for(@account) do |f| %> 
相關問題