2014-03-06 95 views
0

我有一个link_to,我想转换成一个按钮。但不知道如何在button_to调用中传递参数plan_id。按照其他线程,我已经使用button_to调用中的get方法。link_to的作品,但不是button_to与参数传递

作品:

<%= link_to "Sign up", new_subscription_path(:plan_id => plan.id) %> 

没有得到plan_id的数据类型传递:

<%= button_to "Sign up", new_subscription_path(:plan_id => plan.id) , :class => "btn btn-primary btn-large", :method => :get %> 

请你能告诉我什么是错的?

回答

0

button_to有不同的语法,尽量

<%= button_to "Sign up", 
      { controller: :subscriptions, action: :new, plan_id: plan.id, method: :get }, 
      { class: "btn btn-primary btn-large" } %> 
+0

它无法识别订阅控制器。我一整天都在尝试这么多的连击。 Ruby语法对我来说太深奥了。 – user2511030

2
<%= link_to "Sign up",new_subscription_path(:plan_id => plan.id),{ class:"btn btn-primary btn-large"} %> 

,这只会使链接看起来像一个按钮。

+0

+1我喜欢bootstrap的灵活性 – engineersmnky