逐步显示SQLite数据库中的数据

时间:2017-12-07 04:04:43

标签: javascript ruby-on-rails sqlite display

我希望能够一次从我的SQL数据库中显示五个值,然后点击按钮可以显示接下来的五个,直到我显示所有课程。现在这就是我试图展示它们的方式:

 <%= form_for(Stc.new, action:'stcs#create') do |form| %>

 <%= collection_check_boxes(:course_id, Course.all, :id, :title,{}) do 
 |form| %>


 form.label { form.check_box }


 <% end %>
 <%= form.collection_select(:course_id, Course.all,:id, :title, {}, { 
 :multiple => false}) %>


 <%= form.select(:semester, options_for_select([['Fall', 'Fall'], 
 ['Spring', 'Spring'],['Summer', 'Summer']]), :id => 'sel1') %>


 <%= form.select(:year, options_for_select([['2012', '2012'], ['2013', 
'2013'], ['2014', '2014'], ['2015', '2015'], ['2016', '2016'], ['2017', 
'2017']]), :id => 'sel2') %>


<%= form.select(:user_id, options_for_select([[1,@user.id]])) %>
<div class="actions">


 <form id="my_sample_form">

</form>


  <input type="submit" value="Submit" form="my_sample_form">


   <% end %>

 </div>

2 个答案:

答案 0 :(得分:2)

我想你想在这里做分页,你可以使用宝石, 一颗宝石是'will_paginate'宝石。

了解https://github.com/mislav/will_paginate

答案 1 :(得分:1)

你可以试试Kaminari gem进行分页。请注意:

https://github.com/kaminari/kaminari