I have in my controller this:
def boards
@user = User.find_by_slug(params[:id])
@search = @user.boards.solr_search do |s|
s.fulltext params[:search]
s.keywords params[:search]
s.order_by :created_at, :desc
s.paginate :page => params[:page], :per_page => 1
end
@boards = @search.results
respond_to do |format|
format.html { render :layout => nil}# panel.html.erb
format.json { render json: @boards }
format.js
end
end
In my view:
<table id="body_object">
<% for board in @boards %>
<tr class="attributes">
<td>
<%= board.id %>
</td>
<td>
<%= board.name %>
</td>
<td>
<%= board.description %>
</td>
</tr>
<% end %>
</table>
<div id="content_pagination">
<%= paginate @boards, :remote => :true %>
</div>
@user.boards
in controller are every boards that belongs to user.
But I get every boards like Boards.all
.
I want get only every boards that belongs to user.
I have tried with @user.boards
but I have that paginate an array like sth:
@boards = Kaminari.paginate_array(@user.boards).page(params[:page]).per(1)
How can I fix this problem for sunspot?
Edited: Added Console Test
1.9.2-p290 :094 > Board.all.size #I get count boards for Board.all
=> 4
1.9.2-p290 :095 > user = User.first #I get the first
1.9.2-p290 :096 > user.boards.size #I get count for boards belongs to user
=> 2
1.9.2-p290 :098 > user.boards.solr_search.total # This is the problem :O The result must be 2
=> 4