Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting up sunspot geolocation scenario
    primarykey
    data
    text
    <p>I am using <a href="https://github.com/sunspot/sunspot" rel="nofollow">Sunspot</a> for searching and using <a href="http://railscasts.com/episodes/273-geocoder?view=asciicast" rel="nofollow">Geocoder</a> for addresses and then for calculating distances, <a href="https://github.com/jlecour/geokit-rails3" rel="nofollow">Geokit-rails3</a>. </p> <pre><code>class Product &lt; ActiveRecord::Base belongs_to :store searchable do text :name end end class Store &lt; ActiveRecord::Base acts_as_mappable geocoded_by :address, :latitude =&gt; :lat, :longitude =&gt; :lng attr_accessible :lat, :lng, :address has_many :products end </code></pre> <hr> <h2>Question</h2> <p>What I want when typing in a product to search for is also the ability to type an address inside of another field to search for products in that given area with a 30 mile radius.</p> <p>This is my controller which allows me to search for Products:</p> <pre><code>class SearchController &lt; ApplicationController def index @search = Product.search do |q| q.fulltext params[:search] end @products = @search.results end end </code></pre> <p>So I believe the form would look something like this after I am done:</p> <pre><code>&lt;%= form_tag search_path, :method =&gt; 'get' do %&gt; &lt;%= text_field_tag :search, params[:search]" %&gt; &lt;%= submit_tag "Search", :name =&gt; nil %&gt; &lt;p&gt; Search Near: &lt;/p&gt; &lt;%= label_tag :location, "Search nearby an Address" %&gt; &lt;%= text_field_tag :location, params[:location] %&gt; &lt;% end %&gt; </code></pre> <p>I am thinking <code>:location</code> would serve as a virtual attribute for the Stores <code>:address</code> in order for the field to be mapped correctly but this is all speculation.</p> <p>How do I set this all up in order to achieve the specific scenario?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload