2012-02-09 7 views
0

私はレールアプリケーションを開発しており、ned inside pagesコントローラと呼ばれるメソッドを実装しています。私は form_for(@pages) を表示したいが、その私に、このエラーを与える:ここでビューで未定義のメソッドエラーが発生しました

`NoMethodError in Pages#new 

Showing C:/rorapp/app/views/pages/_form.html.erb where line #1 raised: 

undefined method `pages_path' for #<#<Class:0x5a8d840>:0x5a8a558> 
Extracted source (around line #1): 

1: <%= form_for(@pages) do |f| %> 
2: 
3: <% end %> 
Trace of template inclusion: app/views/pages/new.html.erb 

Rails.root: C:/rorapp 

Application Trace | Framework Trace | Full Trace 
app/views/pages/_form.html.erb:1:in `_app_views_pages__form_html_erb__975660997_47429844' 
app/views/pages/new.html.erb:2:in `_app_views_pages_new_html_erb___256256638_47474016' 
app/controllers/pages_controller.rb:11:in `new'` 

は、ページコントローラの私のコントローラメソッドである:ここで

def new 
    @pages = Page.new 

    respond_to do |format| 
    format.html # new.html.erb 
    format.json { render :json => @post } 
    end 
    end 

は、部分的なフォームビュー_form.html.erbであります:

<%= form_for(@pages) do |f| %> 

<% end %> 

とここで私はnew.html.erbビューでそれを使用しています方法です: <%= render 'form' %> 何が問題なのでしょうか?

EDIT -1

ここでは私のすくいルートは出力コマンドです:

home_index GET /home/index(.:format)  {:controller=>"home", :action=>"index"} 
home_search POST /home/search(.:format)  {:controller=>"home", :action=>"search"} 
home__help GET /home/_help(.:format)  {:controller=>"home", :action=>"_help"} 
home_create GET /home/create(.:format)  {:controller=>"home", :action=>"create"} 
pages_index GET /pages/index(.:format)  {:controller=>"pages", :action=>"index"} 
pages_new GET /pages/new(.:format)  {:controller=>"pages", :action=>"new"} 
      POST /pages/new(.:format)  {:controller=>"pages", :action=>"new"} 
pages_edit POST /pages/edit(.:format)  {:controller=>"pages", :action=>"edit"} 
      GET /pages/edit(.:format)  {:controller=>"pages", :action=>"edit"} 
root   /      {:controller=>"home", :action=>"index"} 
       /:controller(/:action(/:id(.:format))) 
+1

'routes.rb'ファイルまたは' rake routes'コマンドの出力を端末 –

+1

に投稿してください。ルートが見つからないという問題があります。 routes.rbファイルを投稿してください – apneadiving

+0

私はroutes.dbを編集中に与えました。 – Maverick

答えて

1

@mad_programmerを - 他の人が提案のように、あなたのroutes.rbファイルにresources :pagesを追加してください。