我的错误:
注意未定义的方法' - @'。
这是为了排序。一个页面上的所有排序都会中断,但其他页面上的所有排序都使用相同的帮助程序而不会中断。它暗示了一些明显的东西吗?
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 `start'
/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)
以下是来自Organization_Controller的代码:
def搜索 params [:q] =''如果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
答案 0 :(得分:0)
我刚刚发现我有多愚蠢! :d
您无法使用 - #!
在控制器中发表评论