Using Sunspot and Rails wrong number of Arguments (1 for 3..4)

148 views Asked by At

I don't know why this is happening. Can anyone explain why I am getting wrong number of arguments for this search? I am just doing a search where you have two fields for the search subject and zip. But when i run the search I get the wrong number of argument error.

Model:

class Profile < ActiveRecord::Base

has_and_belongs_to_many :subjects
belongs_to :user
geocoded_by :zip
after_validation :geocode, :if => :zip_changed?


searchable do
    text :subject_search
    latlon(:location) { Sunspot::Util::Coordinates.new(self.latitude, self.longitude) }
    string :search_near
end


def search_near
    self.zip
end

def subject_search
    subjects.map { |subject| subject.title }
end

end

Controller:

def index
  @search = Profile.search do 
    fulltext params[:subject_search]
    with(:location).in_radius(*Geocoder.coordinates(params[:search_near]), 10)
    if params[:search_near].present?


  end
  @profiles = @search.results
end

View:

 <%= form_tag profiles_path, method: :get do %>
    <p>Enter Zip:</p>
    <%= text_field_tag :search_near, params[:search_near] %>
    <p>Enter Subject:</p>
    <%= text_field_tag :subject_search, params[:subject_search] %>
    <%= submit_tag "Search", name: nil %>
</p>


       <% end %>



Started GET "/profiles?utf8=%E2%9C%93&search_near=33029&subject_search=English+1" for ::1 at 2015-06-26 15:53:28 -0400

Processing by ProfilesController#index as HTML Parameters: {"utf8"=>"✓", "search_near"=>"33029", "subject_search"=>"English 1"} Geocoding API not responding fast enough (use Geocoder.configure(:timeout => ...) to set limit). Completed 500 Internal Server Error in 3010ms

ArgumentError (wrong number of arguments (1 for 3..4)): app/controllers/profiles_controller.rb:8:in block in index' app/controllers/profiles_controller.rb:6:inindex'

Rendered /Users/mikinad/.rvm/gems/ruby-2.1.1/gems/web-console-2.0.0/lib/action_dispatch/templates/rescues/_source.erb (9.1ms) Rendered /Users/mikinad/.rvm/gems/ruby-2.1.1/gems/web-console-2.0.0/lib/action_dispatch/templates/rescues/_trace.html.erb (3.5ms) Rendered /Users/mikinad/.rvm/gems/ruby-2.1.1/gems/web-console-2.0.0/lib/action_dispatch/templates/rescues/_request_and_response.html.erb (1.3ms) Rendered /Users/mikinad/.rvm/gems/ruby-2.1.1/gems/web-console-2.0.0/lib/action_dispatch/templates/rescues/_web_console.html.erb (1.4ms) Rendered /Users/mikinad/.rvm/gems/ruby-2.1.1/gems/web-console-2.0.0/lib/action_dispatch/templates/rescues/diagnostics.html.erb within rescues/layout (60.8ms)

0

There are 0 answers