collectiveidea / awesome_nested_set

An awesome replacement for acts_as_nested_set and better_nested_set.
MIT License
2.39k stars 492 forks source link

ArgumentError - Unknown key: :order in Rails 4.1 #246

Closed jduarte closed 10 years ago

jduarte commented 10 years ago

I'm using the following stack:

With the given model

class Tag < ActiveRecord::Base
  acts_as_nested_set

  belongs_to :account

  has_many :expense_tags
  has_many :expenses, through: :expense_tags
end

The following error occurs:

ArgumentError - Unknown key: :order. Valid keys are: :class_name, :class, :foreign_key, :validate, :autosave, :table_name, :before_add, :after_add, :before_remove, :after_remove, :extend, :primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache:
  activesupport (4.1.0) lib/active_support/core_ext/hash/keys.rb:71:in `block in assert_valid_keys'
  activesupport (4.1.0) lib/active_support/core_ext/hash/keys.rb:69:in `assert_valid_keys'
  activerecord (4.1.0) lib/active_record/associations/builder/association.rb:81:in `validate_options'
  activerecord (4.1.0) lib/active_record/associations/builder/association.rb:61:in `initialize'
  activerecord (4.1.0) lib/active_record/associations/builder/collection_association.rb:18:in `initialize'
  activerecord (4.1.0) lib/active_record/associations/builder/association.rb:46:in `create_builder'
  activerecord (4.1.0) lib/active_record/associations/builder/association.rb:35:in `build'
  activerecord (4.1.0) lib/active_record/associations.rb:1203:in `has_many'
  awesome_nested_set (2.1.6) lib/awesome_nested_set/awesome_nested_set.rb:84:in `acts_as_nested_set'
   () Users/jfduarte/dev/personal/expense-tracker/app/models/tag.rb:2:in `<class:Tag>'
   () Users/jfduarte/dev/personal/expense-tracker/app/models/tag.rb:1:in `<top (required)>'
  activesupport (4.1.0) lib/active_support/dependencies.rb:443:in `block in load_file'
  activesupport (4.1.0) lib/active_support/dependencies.rb:633:in `new_constants_in'
  activesupport (4.1.0) lib/active_support/dependencies.rb:442:in `load_file'
  activesupport (4.1.0) lib/active_support/dependencies.rb:342:in `require_or_load'
  activesupport (4.1.0) lib/active_support/dependencies.rb:480:in `load_missing_constant'
  activesupport (4.1.0) lib/active_support/dependencies.rb:180:in `const_missing'
  activesupport (4.1.0) lib/active_support/dependencies.rb:512:in `load_missing_constant'
  activesupport (4.1.0) lib/active_support/dependencies.rb:180:in `const_missing'
  activesupport (4.1.0) lib/active_support/dependencies.rb:512:in `load_missing_constant'
  activesupport (4.1.0) lib/active_support/dependencies.rb:180:in `const_missing'
  activesupport (4.1.0) lib/active_support/dependencies.rb:512:in `load_missing_constant'
  activesupport (4.1.0) lib/active_support/dependencies.rb:180:in `const_missing'
   () Users/jfduarte/dev/personal/expense-tracker/app/controllers/api/v1/tags_controller.rb:13:in `load_tags'
  activesupport (4.1.0) lib/active_support/callbacks.rb:424:in `block in make_lambda'
  activesupport (4.1.0) lib/active_support/callbacks.rb:143:in `block in halting_and_conditional'
  activesupport (4.1.0) lib/active_support/callbacks.rb:229:in `block in halting'
  activesupport (4.1.0) lib/active_support/callbacks.rb:229:in `block in halting'
  activesupport (4.1.0) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.0) lib/active_support/callbacks.rb:86:in `run_callbacks'
  actionpack (4.1.0) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.1.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
  activesupport (4.1.0) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.0) lib/active_support/notifications.rb:159:in `instrument'
  actionpack (4.1.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.1.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  activerecord (4.1.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.1.0) lib/abstract_controller/base.rb:136:in `process'
  actionview (4.1.0) lib/action_view/rendering.rb:30:in `process'
  actionpack (4.1.0) lib/action_controller/metal.rb:195:in `dispatch'
  actionpack (4.1.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.1.0) lib/action_controller/metal.rb:231:in `block in action'
  actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
  actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:48:in `call'
  actionpack (4.1.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
  actionpack (4.1.0) lib/action_dispatch/journey/router.rb:59:in `call'
  actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:676:in `call'
  meta_request (0.2.9) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
  rack-contrib (1.1.0) lib/rack/contrib/response_headers.rb:17:in `call'
  meta_request (0.2.9) lib/meta_request/middlewares/headers.rb:16:in `call'
  meta_request (0.2.9) lib/meta_request/middlewares/meta_request_handler.rb:13: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.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.1.0) 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.0) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  activerecord (4.1.0) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
  activerecord (4.1.0) lib/active_record/migration.rb:380:in `call'
  actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.1.0) lib/active_support/callbacks.rb:82:in `run_callbacks'
  actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.1.0) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.1.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  better_errors (1.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (1.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (1.1.0) lib/better_errors/middleware.rb:56:in `call'
  actionpack (4.1.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.1.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.1.0) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.0) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.1.0) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.1.0) lib/rails/rack/logger.rb:20:in `call'
  quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
  actionpack (4.1.0) 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.0) 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.0) lib/action_dispatch/middleware/static.rb:64:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  railties (4.1.0) lib/rails/engine.rb:514:in `call'
  railties (4.1.0) lib/rails/application.rb:144:in `call'
  rack (1.5.2) lib/rack/content_length.rb:14:in `call'
  railties (4.1.0) lib/rails/rack/debugger.rb:20:in `call'
  thin (1.6.2) lib/thin/connection.rb:86:in `block in pre_process'
  thin (1.6.2) lib/thin/connection.rb:84:in `pre_process'
  thin (1.6.2) lib/thin/connection.rb:53:in `process'
  thin (1.6.2) lib/thin/connection.rb:39:in `receive_data'
  eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
  thin (1.6.2) lib/thin/backends/base.rb:73:in `start'
  thin (1.6.2) lib/thin/server.rb:162:in `start'
  rack (1.5.2) lib/rack/handler/thin.rb:16:in `run'
  rack (1.5.2) lib/rack/server.rb:264:in `start'
  railties (4.1.0) lib/rails/commands/server.rb:69:in `start'
  railties (4.1.0) lib/rails/commands/commands_tasks.rb:81:in `block in server'
  railties (4.1.0) lib/rails/commands/commands_tasks.rb:76:in `server'
  railties (4.1.0) lib/rails/commands/commands_tasks.rb:40:in `run_command!'
  railties (4.1.0) lib/rails/commands.rb:17:in `<top (required)>'
   () Users/jfduarte/dev/personal/expense-tracker/bin/rails:8:in `<top (required)>'
  spring (1.1.2) lib/spring/client/rails.rb:27:in `call'
  spring (1.1.2) lib/spring/client/command.rb:7:in `call'
  spring (1.1.2) lib/spring/client.rb:26:in `run'
  spring (1.1.2) bin/spring:48:in `<top (required)>'
  spring (1.1.2) lib/spring/binstub.rb:11:in `<top (required)>'
   () Users/jfduarte/dev/personal/expense-tracker/bin/spring:16:in `<top (required)>'
   () rails:3:in `<main>'
jduarte commented 10 years ago

Due to later versions of rails you can't use activerecord methods outside a scope block in associations.

Fixed on 0429d6a82be40081caf40b976fed6a4d6ab294e3

emoreth commented 10 years ago

No release of this fix yet?

parndt commented 10 years ago

I believe it's been in versions 3.0.0.rc3 through 3.0.0.rc6?

emoreth commented 10 years ago

Thanks... Ill update to RC then