如何在链接点击时获得params值

时间:2013-07-05 19:40:19

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

我的观看代码是

<%= form_for(@payment,:url => verify_payment_payment_index_path) do |f| %>
  <%= f.radio_button("amount", "10") %>
  <%= label :amount, '10 Rs',:style => "display:inline" %> <br>
  <%= f.radio_button("amount", "20") %>
  <%= label :amount, '20 rs',:style => "display:inline" %><br>
  <%= f.radio_button("amount", "50") %>
  <%= label :amount, '50 rs',:style => "display:inline" %><br>
  <%= f.radio_button :amount, '100' %> 
  <%= label :amount, '100 rs',:style => "display:inline" %><br>    
  <%= link_to "Make Payment", verify_payment_payment_index_url, 
              :class => "btn",
              :data => { :toggle => "modal",
                         "target" => "#myBox" },
              "for"=>"Make Payment" %>

<% end %>

我想在点击链接“Make Payment”后访问控制器操作中的params中的所有值。那么如何在rails 3中实现它呢?请注意,我必须点击链接打开灯箱,然后提交表格

1 个答案:

答案 0 :(得分:1)

您需要提交表格! 请尝试以下方法:

<%= form_for(@payment,:url => verify_payment_payment_index_path) do |f| %>
   <%= f.radio_button("amount", "10") %>
   <%= label :amount, '10 Rs',:style => "display:inline" %> <br>
   <%= f.radio_button("amount", "20") %>
   <%= label :amount, '20 rs',:style => "display:inline" %><br>
   <%= f.radio_button("amount", "50") %>
   <%= label :amount, '50 rs',:style => "display:inline" %><br>
   <%= f.radio_button :amount, '100' %> 
   <%= label :amount, '100 rs',:style => "display:inline" %><br>

   <%= f.submit "Make Payment", :class=>"btn",:data => {:toggle => "modal","target"=>"#myBox"},"for"=>"Make Payment" %>

<% end %>