I have this action for in my posts_controller.rb:
def index
@search = Post.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
@posts = @search.results
).page(params[:page]).per(20)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @posts }
format.json { render :json => @posts }
end
end
the instance variable @posts is an array.
Post model have an attribute language.
I want get in array @posts only posts with @post.language == "en"
I am using mongoid odm.
How can I do it?
Thank you!
The problem was fixed. I have added this condition to sunspot:
so the method would be:
Thank you very much!