Rails与url参数相同的页面只会更改

时间:2015-01-29 11:56:36

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

实际上这是我的观点,我从mysql数据库获取值,并且我在浏览器中显示基于params page = 1 page = 2 page = 3并且我想在下一个按钮单击的表单中更改params [:page]。 / p>

根据页数= 1,2,3,问题和答案会有所不同,这就是为什么我需要在按钮点击同一页面时更改网址的原因。如下面的网址 http://localhost:3000/responses/new?page=1 提前致谢。

<%= form_for (@response)  do |f| %>
    <% @questions.each do |pgquestion| %>
        <% if pgquestion.group_id == 0 %>
            <%= label :pgquest,pgquestion.description %><br><br>
        <% else %>

            <%= label :pgquest,pgquestion.description %> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

            <% (1..pgquestion.question_value.to_i).each do |i| %>
                <%= radio_button_tag "ans_value[#{ pgquestion.quest_id }]", i %>
            <% end %>
            <br><br>
            <% if pgquestion.question_type == "textarea" %>

                <%= text_area "", "ans_value[#{ pgquestion.quest_id }]" ,size: '80x5'  %><br><br>
            <% else if pgquestion.question_type == "text" %>
                    <%= text_field "", "ans_value[#{ pgquestion.quest_id }]"  %>   <br><br>

            <% end %>

            <% end %>

        <% end %>

    <% end %>
      <div style="text-align: center">
    <%= f.submit 'Prev' ,:class => 'btn btn-primary',:name => "previous_button" %>
    <%= f.submit 'Next', :class => 'btn btn-primary' %> <br><br>

        <p><%= f.submit "Continue" %></p>
        <p><%= f.submit "Back", :name => "previous_button" %></p>

      </div>

<% end %>

1 个答案:

答案 0 :(得分:0)

据我了解您的问题,请使用will_paginate gem https://github.com/mislav/will_paginate