-1

给我错误的代码行是:

<%= 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"
4

1 回答 1

1

这是无效的语法:

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

Ruby 将寻找不存在的变量static_pagesand 。gallery它应该是一个字符串:

<%= button_to 'Search', 'static_pages/gallery' %>
于 2013-03-12T12:53:24.963 回答