RailsCasts Pro episodes are now free!

Learn more or hide this

alikapadia's Profile

GitHub User: alikapadia

Comments by

Avatar

Ok found the issue. Apparently the gem ActiveAdmin (covered in a previous episode) causes conflict because it uses meta_search gem in the gemfile.lock, which makes Product.search use meta_search. A workaround to this is

Sunspot.search(Product) do

Avatar

I am using Rails 3.1 by the way if that matters

Avatar

First, thanks for the awesome tutorial!

I am running in to this error when I try to access the @search.results in my controller: undefined method `results' for #MetaSearch::Searches::Product:0x129d527d8

it seems like the @search always has a full collection of all the products no matter what string I pass it.

Here is how I declared searchable in my product.rb file

searchable do
text :title
end

and here is what my index action looks like in the products_controller.rb

def index
@search = Product.search do
fulltext params[:search]
end
@products = @search.results
respond_to do |format|
format.html
format.xml { render :xml => @products }
end
end

any idea why I keep getting that error?

Avatar

Thanks for the great episode!

I have a question. If my user model has_one appointment model, both of which have decorators declared, is there a way to call the decorator for appointment from the user? like user.appointment.avatar ? or maybe user.appointmentDecorator.avatar ?