My error:
Notice the undefined method '-@' .
This is for a sort by. All sorts on one page break, but all the sorts on other pages use the same helper and do not break. Does it allude to something obvious?
Processing OrganizationsController#search (for ::1 at 2010-05-13 15:42:01) [GET]
Parameters: {"action"=>"search", "controller"=>"organizations", "direction"=>"desc", "_"=>"1273779721464", "order_by"=>"published_at"}
SQL (0.5ms) SHOW TABLES
Organization Columns (2.2ms) SHOW FIELDS FROM `organizations`
NoMethodError (undefined method `-@' for #<Array:0x2f88cc8>):
app/controllers/organizations_controller.rb:190:in `search'
sunspot (1.0.5) lib/sunspot/util.rb:84:in `call'
sunspot (1.0.5) lib/sunspot/util.rb:84:in `instance_eval_or_call'
sunspot (1.0.5) lib/sunspot/search.rb:200:in `build'
sunspot (1.0.5) lib/sunspot/session.rb:45:in `new_search'
sunspot (1.0.5) lib/sunspot/session.rb:53:in `search'
sunspot (1.0.5) lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `search'
sunspot (1.0.5) lib/sunspot.rb:323:in `search'
app/controllers/organizations_controller.rb:183:in `search'
haml (2.2.2) [v] rails/./lib/sass/plugin/rails.rb:19:in `process'
lib/flash_session_cookie_middleware.rb:14:in `call'
vendor/gems/hoptoad_notifier-2.2.2/lib/hoptoad_notifier/rack.rb:27:in `call'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/local/lib/ruby/1.8/webrick/server.rb:95:in `st开发者_StackOverflow社区art'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start'
Rendered rescues/_trace (68.5ms)
Rendered rescues/_request_and_response (0.6ms)
Rendering rescues/layout (internal_server_error)
Here is the code from my Organization_Controller:
def search params[:q] = '' if params[:q] == ORGANIZATION_SEARCH_TEXT
s = Sunspot.search Organization do |query|
query.with(:searchable).equal_to 'true'
query.with(:updated_at).greater_than Time.zone.now-12.months
query.paginate :page => (params[:page] && params[:page].to_i || 1), :per_page => 20
query.keywords(params[:q]) { phrase_fields :quick_description => 3.0, :name => 3.0 } unless params[:q].blank?
-# query.keywords(params[:q]) { phrase_fields :name => 3.0 } unless params[:q].blank?
-# :name , :city
query.order_by(params[:order_by], params[:direction] || 'asc') if params[:order_by] && params[:order_by] != 'distance' -# <-------- This is line 190 / this comment is not in the real code
query.order_by('content_score', 'desc') if params[:q].blank?
end
I just found out how stupid I am! :D
You can't comment things in a controller with -# !
精彩评论