现在我正在尝试使用kaminari设置ajax重新加载分页系统,如twitter。但是我收到了一条错误消息。你能提一些建议吗?
☆错误信息
ActionController::RoutingError at /members
undefined method `paginates_per' for #<Class:0x007f8afcd2e428>
☆member.rb
class Member < ActiveRecord::Base
default_scope :order => 'created_at DESC'
paginates_per 15
end
☆index.html.erb
<h1>Listing users</h1>
<p>※登録されているユーザーのリストです。</p>
<div class= "form_index">
<%= form_tag({:action=>"index"}, {:method=>"get"}) do %>
<div class="from_field_index">
<%= text_field_tag 'name' %>
<%= submit_tag '名前検索' %>
<% end %>
</div>
</div>
<div id="lists">
<%= render 'index' %>
</div>
<%= paginate @members, remote: ture %>
☆_index.html.erb
<table class="table">
<tr>
<th>写真</th>
<th>名前</th>
<th>分野</th>
<th>場所</th>
<th>経験</th>
<th>Follow</th>
<%# if Member.find(session[:user_id]).admin %>
<%# end %>
</tr>
<% @members.each do |member| %>
<tr>
<td>
<% if member.provider %>
<%=image_tag member.image ,:size=>'30x30'%>
<% elsif member.avatar_file_name %>
<%= image_tag member.avatar.url(:thumb), :width =>'30px', :height =>'30px' %>
<% else %>
<%= image_tag "love.png", :size=>'30x30' %>
<% end %>
</td>
<td>
<a href="/members/<%= member.id %>"><%= member.name %></a>
<% if member.provider == "facebook" %>
<a target="_blank" href="http://www.facebook.com/<%=member.uid %>"> <%=image_tag "fb.png" ,:size=>'20x20'%> </a>
<% elsif member.provider == "twitter" %>
<a target="_blank" href="http://www.twitter.com/<%=member.name %>"> <%=image_tag "twitter.png" ,:size=>'20x20'%> </a>
<% end %>
</td>
<td><%= member.field %></td>
<td>
<% if member.url.present? %>
<%=link_to member.place ,member.url ,:target=>["_blank"] %>
<% else %>
<%= member.place %>
<% end %>
</td>
<td><%= member.experience %></td>
<td>
<div class="onoff">
<% unless session[:user_id] == member.id %>
<% if @Frids.include? member.id%>
<%= link_to'解除', {:controller => 'members', :action => 'index', :id =>
member.id}, class: "btn btn-midium btn-warning"%><br/>
<% else %>
<%= link_to'follow', {:controller => 'members', :action => 'index', :id =>
member.id}, class: "btn btn-midium btn-primary"%><br/>
<% end %>
<% end %>
</div>
<%#= member.friends.count %>
</td>
<% if Member.find(session[:user_id]).admin %>
<td><%= link_to 'Destroy', member, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<% end %>
</tr>
<% end %>
</table>
☆index.js.erb的
$('#lists').append("<%= escape_javascript(render 'index', object: @members) %>");
答案 0 :(得分:0)
将它放入Gemfile并重新启动服务器后,您确定bundle install
了吗?