koudoku
koudoku copied to clipboard
undefined method `__sort_option__' for :price:Symbol
After installing like the README, I get the following error
NoMethodError at /pricing undefined method `__sort_option__' for :price:Symbol
here it is my env:
$ ruby -v ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux] $ gem list koudoku *** LOCAL GEMS *** koudoku (0.0.11) $ gem list mongoid *** LOCAL GEMS *** mongoid (4.0.0)
Do you have a stack trace for the error?
@yas4891 sure, here it is :
lsoave@basenode:~/Github/gitwatcher$ rails s => Booting Puma => Rails 4.1.4 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option) => Ctrl-C to shutdown server Puma 2.9.1 starting... * Min threads: 0, max threads: 16 * Environment: development * Listening on tcp://0.0.0.0:3000 Started GET "/" for 127.0.0.1 at 2014-09-26 17:16:57 +0200 Processing by HomeController#index as HTML Rendered home/_main_search.html.erb (1.0ms) Rendered home/index.html.erb within layouts/application (5.5ms) Completed 200 OK in 948ms (Views: 928.1ms) Started GET "/pricing" for 127.0.0.1 at 2014-09-26 17:17:46 +0200 Processing by Koudoku::SubscriptionsController#index as HTML Completed 500 Internal Server Error in 7ms NoMethodError - undefined method `__sort_option__' for :price:Symbol: origin (2.1.1) lib/origin/optional.rb:173:in `block (2 levels) in order_by' origin (2.1.1) lib/origin/optional.rb:172:in `each' origin (2.1.1) lib/origin/optional.rb:172:in `block in order_by' origin (2.1.1) lib/origin/optional.rb:314:in `block in option' origin (2.1.1) lib/origin/optional.rb:312:in `tap' origin (2.1.1) lib/origin/optional.rb:312:in `option' origin (2.1.1) lib/origin/optional.rb:171:in `order_by' (eval):2:in `order' koudoku (0.0.11) app/controllers/koudoku/subscriptions_controller.rb:9:in `load_plans' activesupport (4.1.4) lib/active_support/callbacks.rb:424:in `block in make_lambda' activesupport (4.1.4) lib/active_support/callbacks.rb:143:in `call' activesupport (4.1.4) lib/active_support/callbacks.rb:143:in `block in halting_and_conditional' activesupport (4.1.4) lib/active_support/callbacks.rb:149:in `call' activesupport (4.1.4) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional' activesupport (4.1.4) lib/active_support/callbacks.rb:149:in `call' activesupport (4.1.4) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional' activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.4) lib/active_support/callbacks.rb:229:in `call' activesupport (4.1.4) lib/active_support/callbacks.rb:229:in `block in halting' activesupport (4.1.4) lib/active_support/callbacks.rb:229:in `call' activesupport (4.1.4) lib/active_support/callbacks.rb:229:in `block in halting' activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `call' activesupport (4.1.4) lib/active_support/callbacks.rb:166:in `block in halting' activesupport (4.1.4) lib/active_support/callbacks.rb:86:in `call' activesupport (4.1.4) lib/active_support/callbacks.rb:86:in `run_callbacks' actionpack (4.1.4) lib/abstract_controller/callbacks.rb:19:in `process_action' actionpack (4.1.4) lib/action_controller/metal/rescue.rb:29:in `process_action' actionpack (4.1.4) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action' activesupport (4.1.4) lib/active_support/notifications.rb:159:in `block in instrument' activesupport (4.1.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument' activesupport (4.1.4) lib/active_support/notifications.rb:159:in `instrument' actionpack (4.1.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action' actionpack (4.1.4) lib/action_controller/metal/params_wrapper.rb:250:in `process_action' () home/lsoave/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/bundler/gems/searchkick-670db2f6851c/lib/searchkick/logging.rb:61:in `process_action' actionpack (4.1.4) lib/abstract_controller/base.rb:136:in `process' actionview (4.1.4) lib/action_view/rendering.rb:30:in `process' actionpack (4.1.4) lib/action_controller/metal.rb:196:in `dispatch' actionpack (4.1.4) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' actionpack (4.1.4) lib/action_controller/metal.rb:232:in `block in action' actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:82:in `call' actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:82:in `dispatch' actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:50:in `call' actionpack (4.1.4) lib/action_dispatch/journey/router.rb:71:in `block in call' actionpack (4.1.4) lib/action_dispatch/journey/router.rb:59:in `each' actionpack (4.1.4) lib/action_dispatch/journey/router.rb:59:in `call' actionpack (4.1.4) lib/action_dispatch/routing/route_set.rb:678:in `call' omniauth (1.2.2) lib/omniauth/strategy.rb:186:in `call!' omniauth (1.2.2) lib/omniauth/strategy.rb:164:in `call' omniauth (1.2.2) lib/omniauth/builder.rb:59:in `call' rack (1.5.2) lib/rack/etag.rb:23:in `call' rack (1.5.2) lib/rack/conditionalget.rb:25:in `call' rack (1.5.2) lib/rack/head.rb:11:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/params_parser.rb:27:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/flash.rb:254:in `call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context' rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/cookies.rb:560:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' activesupport (4.1.4) lib/active_support/callbacks.rb:82:in `run_callbacks' actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:27:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/reloader.rb:73:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/remote_ip.rb:76:in `call' better_errors (2.0.0) lib/better_errors/middleware.rb:84:in `protected_app_call' better_errors (2.0.0) lib/better_errors/middleware.rb:79:in `better_errors_call' better_errors (2.0.0) lib/better_errors/middleware.rb:57:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' railties (4.1.4) lib/rails/rack/logger.rb:38:in `call_app' railties (4.1.4) lib/rails/rack/logger.rb:20:in `block in call' activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `block in tagged' activesupport (4.1.4) lib/active_support/tagged_logging.rb:26:in `tagged' activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `tagged' railties (4.1.4) lib/rails/rack/logger.rb:20:in `call' quiet_assets (1.0.3) lib/quiet_assets.rb:23:in `call_with_quiet_assets' actionpack (4.1.4) lib/action_dispatch/middleware/request_id.rb:21:in `call' rack (1.5.2) lib/rack/methodoverride.rb:21:in `call' rack (1.5.2) lib/rack/runtime.rb:17:in `call' activesupport (4.1.4) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call' rack (1.5.2) lib/rack/lock.rb:17:in `call' actionpack (4.1.4) lib/action_dispatch/middleware/static.rb:64:in `call' rack (1.5.2) lib/rack/sendfile.rb:112:in `call' railties (4.1.4) lib/rails/engine.rb:514:in `call' railties (4.1.4) lib/rails/application.rb:144:in `call' rack (1.5.2) lib/rack/content_length.rb:14:in `call' puma (2.9.1) lib/puma/server.rb:490:in `handle_request' puma (2.9.1) lib/puma/server.rb:361:in `process_client' puma (2.9.1) lib/puma/server.rb:254:in `block in run' puma (2.9.1) lib/puma/thread_pool.rb:92:in `call' puma (2.9.1) lib/puma/thread_pool.rb:92:in `block in spawn_thread' Started POST "/__better_errors/bc42d240e611f34d/variables" for 127.0.0.1 at 2014-09-26 17:17:46 +0200
... moreover, with better_errors gem installed you get pointed to criterion.__sort_option__.each_pair do |field, direction| in origin (2.1.1) lib/origin/optional.rb (block (2 levels) in order_by line 4):
def order_by(*spec)
option(spec) do |options, query|
spec.compact.each do |criterion|
criterion.__sort_option__.each_pair do |field, direction|
add_sort_option(options, field, direction)
end
query.pipeline.push("$sort" => options[:sort]) if aggregating?
end
end
Hi @lgs I've never used MongoDB, but judging from the stack trace the problem does not lie with Koudoku. I've found the following link that describes a solution to a somewhat similar problem - maybe it helps: https://groups.google.com/forum/#!msg/mongoid/2QqpGlfHRQA/Lu7KWWdI20YJ
Hi Guys, I am runing into exactly the same problem. Does anybody know how to fix this?
Ok so i fixed it with the following: in plan.rb (when using mongoid) add:
def self.order(type)
super(type.asc)
end
I think this an error in koudoku and not in mongoid though. As clearly stated in the group link given earlier.
@heldopslippers
I scanned through the groups link and only see a mention that this happens if you define a default sort order without a sort direction. Koudoku does not define any default sort order at all.
Also the source code in the Groups link uses embeds_many, whereas Koudoku uses has_many.
Did I mention that I am completely clueless about Mongoid?