Hi every body.

I have the following association:
offreservice     has_and_belongs_to_many :entiteservices
entiteservice   belongs_to :commune

In the communes table i have the "lattitude and longitude" columns for
distance calculation with GEOKIT

In Commune Model i have :
       acts_as_mappable :default_units => :kms,
                   :default_formula => :sphere,
                   :distance_field_name => :distance,
                   :lat_column_name => :lattitude,
                   :lng_column_name => :longitude

In Offreservice Model i have:
         acts_as_mappable :through => { :entiteservices => :commune }

I am using Geokit to order and filter the list view like the following
in offreservices controller:

#to filter the list
  def conditions_for_collection
    "distance < 10" if session[:usager_id] != nil
  end

  #List sorting based on distance
  def custom_finder_options
    if session[:usager_id] != nil
      commune_usager = Usager.find(session[:usager_id]).commune #city
of the current usager
      commune_usager_lat = commune_usager.lattitude  #lattitude of
current usager's city
      commune_usager_long = commune_usager.longitude #longitude of
current usager's city
      communes = Commune.find(:all, :origin => [commune_usager_lat,
commune_usager_long],
                          :conditions  => "distance <= 10")
      communes.sort_by_distance_from( [commune_usager_lat,
commune_usager_long])
      {:order => 'distance ASC', :origin => [commune_usager_lat,
commune_usager_long], :within=>10}
    else
      {}
    end
  end

1) How can i show that "distance" calculated by Geokit for each record
on offreservices list view ?

2) May be after that filtering, there is no record matching.
    So i wanted to add criteria (check_box with 2 or 3 options) on
Search view which can extend the search on 20 kms (for example or
more...)  from the current_usager's (session[:usager_id]) commune.


Any idea on how i can solve those 2 questions?

Thanks in advance for your help

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en.

Reply via email to