Currently testing with just one or two each, but they are not
limited.

Some spots are tied to trip_day too, but it's just for order purpose.
Lemme know if you need to look into that code too.

I also have the following codes:

spot_trip.rb
=====
class SpotTrip < ActiveRecord::Base
  belongs_to :trip
  belongs_to :spot

  def spot_name
    spot.name if spot.try(:name)
  end

  def spot_type
    spot.spot_type if spot.try(:spot_type)
  end
end


On Nov 1, 5:08 pm, Pat Allan <[email protected]> wrote:
> Okay... how many spots are usually tied to a trip? A few? Dozens? Hundred?
>
> --
> Pat
>
> On 01/11/2010, at 8:02 PM, Victor wrote:
>
> > Hi Pat,
>
> > Yes, rebuilt is done, and I did not change the model.
>
> > Yes, related trip is not being return.
>
> > For example:
>
> > Trip: 3 day Victoria trip.
> > Spots in the trip above: Old Melbourne Gaol, Melbourne Museum, The Art
> > Gallery
>
> > Each spot has an individual page of course.
>
> > When I search Victoria, the trip above will show in result. But if I
> > search "Old Melbourne Gaol", or any of the spots.name, it returns 0
> > result. This actually happens to the site-wide search.
>
> > By the way, the codes I gave were just snippets, which I think they
> > are the only one related.
>
> > Thanks.
>
> > On Nov 1, 4:57 pm, Pat Allan <[email protected]> wrote:
> >> Hi Victor
>
> >> Just to confirm: are you searching for a word that appears in a spot name 
> >> (or city, state, country), and the related trip is not being returned?
>
> >> Have you run 'rake ts:rebuild' since adding those fields?
>
> >> Cheers
>
> >> --
> >> Pat
>
> >> On 01/11/2010, at 7:51 PM, Victor wrote:
>
> >>> Hi Pat,
>
> >>> I'm using the following:
>
> >>> Rails 2.3.8, Sphinx 1.10-beta, TS 1.3.20
>
> >>> If you looked at the code below, I would like to search Spots
> >>> (different model) name, city, state, country listed in Trips. Somehow
> >>> my search filter only works on the name of the Trip, but not the spots
> >>> in it.
>
> >>> trip.rb
> >>> =====
> >>> class Trip < ActiveRecord::Base
> >>>  has_many :spots, :through => :spot_trips
>
> >>> # ThinkingSphinx Index
> >>>  define_index do
> >>>    indexes :name, :sortable => true
> >>>    indexes duration
> >>>    indexes spots.name, :as => :spot_name
> >>>    indexes spots.city, :as => :spot_city
> >>>    indexes spots.state, :as => :spot_state
> >>>    indexes spots.country, :as => :spot_country
> >>>    has budget, created_at, rating_average
> >>>  end
> >>> end
>
> >>> trips_controller.rb
> >>> =======
> >>> class TripsController < ApplicationController
> >>>  before_filter :require_user, :except => [:show, :index]
>
> >>>  def index
> >>>    if params[:filter] == 'on'
> >>>      country = params[:country] == 'All' ? {} : {:spot_country =>
> >>> params[:country]}
> >>>      duration = params[:days].blank? ? "" : params[:days]
>
> >>>      if !duration.blank? && country
> >>>        conditions = {:duration => duration}.merge(country)
> >>>      elsif !duration.blank? && country.blank?
> >>>        conditions = {:duration => duration}
> >>>      else country && duration.blank?
> >>>        conditions = country
> >>>      end
>
> >>>      keyword = params[:keyword].blank? ? "" : params[:keyword]
>
> >>>      case params[:order]
> >>>      when 'date_descend'
> >>>        order = {:order => 'created_at DESC'}
> >>>      when 'date_ascend'
> >>>        order = {:order => 'created_at ASC'}
> >>>      when 'rating_descend'
> >>>        order = {:order => 'rating_average DESC'}
> >>>      when 'rating_ascend'
> >>>        order = {:order => 'rating_average ASC'}
> >>>      when 'budget_dscend'
> >>>        order = {:order => 'budget DESC'}
> >>>      when 'budget_ascend'
> >>>        order = {:order => 'budget ASC'}
> >>>      else
> >>>        order = {}
> >>>      end
>
> >>>      results = Trip.search params[:keyword], {:conditions =>
> >>> conditions, :star => true}.merge(order)
> >>>     �...@trips = results.paginate(:page => params[:page])
> >>>    else
> >>>     �...@trips = Trip.paginate(:all, :page => params[:page], :order =>
> >>> 'created_at DESC')
> >>>    end
> >>>  end
>
> >>> index.html.erb for trip
> >>> =====
> >>> I have these for filters:
>
> >>> <%= text_field_tag 'keyword' %>
> >>> <select name="country">
> >>>  <option>All</option>
> >>>  <option value="Afghanistan">Afghanistan</option>
> >>>  .
> >>>  .
> >>> </select>
> >>> <input class="duration" name="days" />
> >>> <select name="order">
> >>>  <option value="date_descend" <%= params[:order] == 'date_dscend' ?
> >>> 'selected' : ''%>>
> >>>    Date: Latest to earliest
> >>>  </option>
> >>>  <option value="date_ascend" <%= params[:order] == 'date_ascend' ?
> >>> 'selected' : ''%>>
> >>>    Date: Earliest to latest
> >>>  </option>
> >>>  <option value="rating_descend" <%= params[:order] ==
> >>> 'rating_descend' ? 'selected' : ''%>>
> >>>    Rating: Highest to lowest
> >>>  </option>
> >>>  <option value="rating_ascend" <%= params[:order] ==
> >>> 'rating_ascend' ? 'selected' : ''%>>
> >>>    Rating: Lowest to highest
> >>>  </option>
> >>> </select>
>
> >>> Thanks.
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups 
> >>> "Thinking Sphinx" group.
> >>> To post to this group, send email to [email protected].
> >>> To unsubscribe from this group, send email to 
> >>> [email protected].
> >>> For more options, visit this group 
> >>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Thinking Sphinx" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > For more options, visit this group 
> > athttp://groups.google.com/group/thinking-sphinx?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to