ruby on rails - Problems to seach ActsAsTaggableOn with sunspot -
i've setup sunspot , i'm searching fine in place.name
field
now want search "acts taggable" tags
i've setup 2 contexts taggable, categories
with model , controller i'm not getting errors when search tag name sunspot doesn't return results.
i've run rake sunspot:reindex
, rake sunspot:solr:reindex
no change.
when run place.last.categories
in rails console 1 array ["category one","category 2"]
model
class place < activerecord::base extend friendlyid friendly_id :name, use: :slugged searchable :auto_index => true, :auto_remove => true text :name, :stored => true string :category_list, :multiple => true, :stored => true end acts_as_votable acts_as_mappable :default_units => :kms, :lat_column_name => :latitude, :lng_column_name => :longitude validates_presence_of :name , :state, :city, :neighborhood, :adress,:latitude, :longitude belongs_to :user acts_as_ordered_taggable_on :categories, :obstacles end
controller
class placescontroller < applicationcontroller before_action :set_place, only: [:show, :edit, :update, :destroy, :upvote, :downvote, :favorite] before_action :authenticate_user!, except: [:index, :show] # /places # /places.json def index @search = place.search fulltext params[:search] end @places = @search.results end
in case should add searchable
block in tag model.in memory,the tag model may have assoiations,if want know more how index rails associations,you may checkout this
Comments
Post a Comment