ruby on rails - Sunspot gem return all result -


sunspot gem return data select * contents

my model

  has_many :pictures, :dependent => :destroy    searchable      text :title      integer :id      text :pictures        pictures.map { |picture| picture.image_file_name }      end     end 

and calling section code is

    @search =  contents.search           fulltext params[:q].to_s          fields(:title)          fields(:image_file_name)     end   looking filter result search multiple fields , multiple tables 

one thing need change in code fields attribute trying search. in model have defined searchable field as:

text :pictures    pictures.map { |picture| picture.image_file_name } end 

hence, searchable field named pictures. in controller search, trying search on field image_file_name, whereas should searching on field pictures.

so, search code needs this:

@search =  contents.search           fulltext params[:q].to_s            fields(:title, :pictures)           end end 

if still continue facing issues, please post code using in view well.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -