ruby on rails - Listing out searches in index -
i'm having issues showing out of drinks in index.html.haml. have moved start using thinking sphinx searching after watching ryan bates' (thinking sphinx railscast. part of move sphinx changed @drinks = drink.all
@drinks = drink.search(params[:search])
, not showing drink names on index page
drink model
class drink < activerecord::base attr_accessible :name, :detail, :recipe_steps_attributes has_many :recipe_steps, :dependent => :destroy has_many :ingredients, through: :recipe_steps has_one :glass validates_uniqueness_of :name, case_sensitive: false accepts_nested_attributes_for :recipe_steps, :reject_if => lambda { |a| a[:amount].blank? }, :allow_destroy => true define_index indexes :name indexes ingredients.name as: :ingredient_name end end
drink controller index
def index @drinks = drink.search(params[:search]) if current_user @cabinet = cabinet.find(current_user.id) end end
drink index.haml
= form_tag drinks_path, method: :get .field = text_field_tag :search, params[:search] = submit_tag "search", name: nil - @drinks.each |drink| = drink.name
i able reply own question. problem hadn't re-indexed after added records database. not showing when trying print them out in block.
as toml suggested, best way of dealing have cron job periodically run
rake ts:rebuild
ruby-on-rails ruby-on-rails-3 thinking-sphinx
No comments:
Post a Comment