将按钮转到具有相同功能的链接

时间:2011-03-20 06:59:00

标签: ruby-on-rails ruby ruby-on-rails-3 button hyperlink

所以我有这个按钮:

<%= button_to "+1", video_votes_path( :video_id => video.id, :type => "up" ), :remote => true %>

它调用video_votes控制器中的create方法,并设置params [:type]。我想把这个按钮变成一个链接,这样就完全一样了。我该怎么做?

2 个答案:

答案 0 :(得分:1)

button_to "+1", video_votes_path( :video_id => video.id, :type => "up" ), :remote => true
=>
link_to "+1", video_votes_path( video, :type => "up"), :remote => true, :method => :post

答案 1 :(得分:0)

使用额外参数button_tolink_to_remote更改为:method => :post,然后取出remote

呃,如果你想获得GET,请忽略method