给我错误的代码行是:
<%= 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"
答案 0 :(得分:1)
这是无效的语法:
<%= button_to 'Search', static_pages/gallery %>
Ruby会查找不存在的变量static_pages
和gallery
。它应该是一个字符串:
<%= button_to 'Search', 'static_pages/gallery' %>