2013-03-12 48 views
-1

的代碼給我錯誤的代碼行是:爲什麼在使用button_to時出現錯誤?

<%= button_to 'Search', static_pages/gallery %> 

的錯誤是:

未定義的局部變量或方法`static_pages'

這裏是我的路線:

match "/home" => "static_pages#home" 
match "/gallery" => "static_pages#gallery" 

get "static_pages/home" 
get "static_pages/gallery" 
post "static_pages/gallery" 
+1

只是爲了給你一個微調,你基本上沒有提供你正在做的事情的背景,所以它將不可能給你一個特定的答案。很有可能你已經使用'link_to'創建了一個沒有路由或控制器動作的鏈接來匹配它。提供更多細節。 – DVG 2013-03-12 11:54:02

回答

1

這是無效的語法:

<%= button_to 'Search', static_pages/gallery %> 

紅寶石將尋找變量static_pagesgallery,這是不存在的。它應該是一個字符串,而不是:

<%= button_to 'Search', 'static_pages/gallery' %> 
相關問題