controller
def all_mail @user = User.all.page(params[:page]).per(APP_CONFIG[:user_all_email]) end
views
all_all.html.erb:
<form role="form"> <div class="form-group"> <div class="panel panel-default"> <div class="panel-heading">用户列表</div> <div id="paginator"> <%= paginate @user, remote: true %> </div> <table class="table"> <thead><th>ID</th><th>姓名</th><th>邮箱</th><th>操作</th></thead> <tbody id="institutions"> <%= render 'user_mail' %> </tbody> </table> </div> </div> </form>
_user_mail.html.erb:
<% if @user.present? %> <% @user.each do |u|%> <tr> <td><%= u.id %></td> <td><%= u.name %></td> <td><%= u.email %></td> <td><button type="button" οnclick="addmail('<%= u.email %>');" class='btn' name="button"><i class='fa fa-plus'></i></button></td> </tr> <% end %> <% end %>
all_mail.js.erb
$('tbody#institutions').html('<%= escape_javascript(render "user_mail") %>'); $('#paginator').html('<%= escape_javascript(paginate(@user, :remote => true).to_s) %>');