2015-03-13 114 views
0

我安裝並配置了簡單導航,如描述的here (simple-navigation configuration)簡單導航:未定義的局部變量或方法`根'

我修改配置/ navigation.rb(只包含一個菜單項):

primary.item :key_1, 'Home', root 

的config/routes.rb中包含:

root 'static_pages#home' 

耙路線包含字符串:

Prefix Verb URI Pattern Controller#Action 
    root GET /   static_pages#home 

應用/視圖/佈局/ application.html.erb包含:

<%= render "layouts/header" %> 

應用/視圖/佈局/ _header.html.erb包含:

<%= render "layouts/main_nav" %> 

應用程序/ views/layouts/_main_nav.html.erb包含一個字符串:

<%= render_navigation %> 

之後,我得到了一個錯誤:

Showing <...>_main_nav.html.erb where line #1 raised: 
undefined local variable or method `root' 

爲什麼寧靜的路線傭工和命名的路由助手是「隱形」在這種情況下?我嘗試了路由表中的所有前綴。

回答

0

的第三參數應該是一個URL或路徑,因此在配置/ navigation.rb改變rootroot_path。你的菜單項應該是這樣的:

primary.item :key_1, 'Home', root_path 
+0

謝謝,Keith :) – c80609a 2015-03-15 11:31:43

相關問題