2013-03-12 52 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' %> 
相关问题