2011-08-19 73 views
1

为什么这会工作?为什么“link_to”工作,但不是“button_to”

<%= link_to "New Item", new_site_care_path, {:class => "button_bottom"} %> 

而这(唯一的变化是从的link_to到button_to)...

<%= button_to "New Item", :url => new_site_care_path, {:class => "button_bottom"} %> 

...生产:

No route matches "/site_cares/new" 

更新 - 路线信息 - 路线文件:

resources :site_cares, :except => :show 

耙路线:

new_site_care GET /site_cares/new(.:format) {:action=>"new", :controller=>"site_cares"} 

回答

2

我认为button_to默认使用后,我的ROR路线的技能是有点生疏,但我认为还有你的路由使用GET。

有没有在这个问题进一步信息 - Button_to in Ruby on Rails bad route

+0

可能违反的一些在Rails社区的乡亲情面的,但有一个div创建了自己的“的link_to”按钮。我不认为用户注意到按钮是用于文章和链接在别处使用吗? ps ...很高兴我得把你置于2000分......不是你注意到那种东西:=] – Jay

+0

@Jay-感谢推动我超过2000的障碍:)认为你一定做得对按钮的东西! – ipr101

相关问题