如何在rails 4.1中使用button_to click事件

时间:2014-08-23 05:18:19

标签: ruby-on-rails-4

我是rails的新手。我想知道如何在rails 4.1中使用click事件。 在menus_controller中:

def index 
  @menus=Menu.where(:hotel_id=>@hotel.id).sorted     
  @cart = current_cart

if :MEAL
  @menus=Menu.where(:hotel_id=>params[:hotel_id],:item_type=>'Meal').sorted     
  @cart = current_cart    
end
菜单/索引中的

:     <%=button_to("MEAL",{:controller=>'menus',:action=>'index',:hotel_id=>params[:hotel_id]}, class:'linkstyle ')%>

使用上面的代码后,页面会被重定向到Menus#create,为什么会这样? 在索引页面中我有这个按钮,我想在点击这个按钮后停留在同一页面,这个按钮将在控制器的索引方法中调用if块。

0 个答案:

没有答案