Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate_token calls find_first which require order param #2487

Closed
smusiol opened this issue Jul 4, 2013 · 9 comments
Closed

generate_token calls find_first which require order param #2487

smusiol opened this issue Jul 4, 2013 · 9 comments

Comments

@smusiol
Copy link

smusiol commented Jul 4, 2013

Rails: 4.0.0
Devise: 3.0.0rc
Warden: 1.2.1

When creating object with FactoryGirl I receive "The method .order() must contain arguments.". I can see that generate_token from devise calls find_first method which does not pass argument for order. In active_record 4 order method there is a method called check_if_method_has_arguments!("order", args) which raises error if order has no arguments.

["/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/relation/query_methods.rb:1040:in check_if_method_has_arguments!'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/relation/query_methods.rb:275:inorder'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/orm_adapter-0.4.0/lib/orm_adapter/adapters/active_record.rb:23:in find_first'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/devise-3.0.0.rc/lib/devise/models/authenticatable.rb:286:inblock in generate_token'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/devise-3.0.0.rc/lib/devise/models/authenticatable.rb:284:in loop'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/devise-3.0.0.rc/lib/devise/models/authenticatable.rb:284:ingenerate_token'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/devise-3.0.0.rc/lib/devise/models/token_authenticatable.rb:82:in authentication_token'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/devise-3.0.0.rc/lib/devise/models/token_authenticatable.rb:48:inreset_authentication_token'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/devise-3.0.0.rc/lib/devise/models/token_authenticatable.rb:59:in ensure_authentication_token'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:397:in_run__129427932__save__callbacks'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in run_callbacks'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/callbacks.rb:299:increate_or_update'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/persistence.rb:128:in save!'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/validations.rb:57:insave!'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/attribute_methods/dirty.rb:41:in save!'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/transactions.rb:275:inblock in save!'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/transactions.rb:326:in block in with_transaction_returning_status'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/connection_adapters/abstract/database_statements.rb:200:intransaction'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/transactions.rb:209:in transaction'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/transactions.rb:323:inwith_transaction_returning_status'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activerecord-4.0.0/lib/active_record/transactions.rb:275:in save!'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/configuration.rb:14:inblock in initialize'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:in []'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:15:increate'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:12:in block in result'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:intap'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/strategy/create.rb:9:in result'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/factory.rb:42:inrun'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:23:in block in run'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/notifications.rb:161:ininstrument'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/factory_runner.rb:22:in run'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/factory_girl-4.2.0/lib/factory_girl/strategy_syntax_method_registrar.rb:19:inblock in define_singular_strategy_method'",
"(pry):1:in block (4 levels) in <top (required)>'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:328:ineval'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:328:in evaluate_ruby'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:278:inre'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:254:in rep'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:234:inblock (3 levels) in repl'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:232:in loop'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:232:inblock (2 levels) in repl'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:231:in catch'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:231:inblock in repl'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:230:in catch'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:230:inrepl'",
"/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_class.rb:170:in start'", "/home/szymon/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/core_extensions.rb:43:inpry'",
"/home/szymon/test/test_spec.rb:38:in `block (4 levels) in <top (required)>'"]

@josevalim
Copy link
Contributor

Thanks @smusiol but I could not reproduce your failure. Do you have a simple way to reproduce it? I checked that the generate_token code is being called and it doesn't print the warning above, even without the order.

@iHiD
Copy link

iHiD commented Jul 29, 2013

I'm getting this in development too when logging in using devise.

It's reproducible for me here in an app I started working on today: https://github.com/iHiD/silicon-canal/tree/ac78c31e218b0d70cc081fb193e9e57fe12bb822

I'll try and look further tomorrow.

ArgumentError (The method .order() must contain arguments.):
activerecord (4.0.0) lib/active_record/relation/query_methods.rb:1040:in `check_if_method_has_arguments!'
activerecord (4.0.0) lib/active_record/relation/query_methods.rb:275:in `order'
orm_adapter (0.4.0) lib/orm_adapter/adapters/active_record.rb:23:in `find_first'
devise (3.0.0) lib/devise/models/authenticatable.rb:246:in `find_first_by_auth_conditions'
devise (3.0.0) lib/devise/models/authenticatable.rb:242:in `find_for_authentication'
devise (3.0.0) lib/devise/models/database_authenticatable.rb:136:in `find_for_database_authentication'
devise (3.0.0) lib/devise/strategies/database_authenticatable.rb:8:in `authenticate!'
warden (1.2.3) lib/warden/strategies/base.rb:53:in `_run!'
warden (1.2.3) lib/warden/proxy.rb:354:in `block in _run_strategies_for'
warden (1.2.3) lib/warden/proxy.rb:349:in `each'
warden (1.2.3) lib/warden/proxy.rb:349:in `_run_strategies_for'
warden (1.2.3) lib/warden/proxy.rb:319:in `_perform_authentication'
warden (1.2.3) lib/warden/proxy.rb:127:in `authenticate!'
devise (3.0.0) app/controllers/devise/sessions_controller.rb:15:in `create'
actionpack (4.0.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.0.0) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.0.0) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (4.0.0) lib/active_support/callbacks.rb:453:in `_run__1174939751829309731__process_action__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.0.0) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.0) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (4.0.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.0.0) lib/abstract_controller/base.rb:136:in `process'
actionpack (4.0.0) lib/abstract_controller/rendering.rb:44:in `process'
actionpack (4.0.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.0.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.0.0) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/mapper.rb:44:in `call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call'
request_store (1.0.5) lib/request_store/middleware.rb:9:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241: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.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.0) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__295620804579101429__call__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.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.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/application.rb:97:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
thin (1.5.1) lib/thin/connection.rb:81:in `block in pre_process'
thin (1.5.1) lib/thin/connection.rb:79:in `catch'
thin (1.5.1) lib/thin/connection.rb:79:in `pre_process'
thin (1.5.1) lib/thin/connection.rb:54:in `process'
thin (1.5.1) lib/thin/connection.rb:39:in `receive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run_machine'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
thin (1.5.1) lib/thin/backends/base.rb:63:in `start'
thin (1.5.1) lib/thin/server.rb:159: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.0.0) lib/rails/commands/server.rb:84:in `start'
railties (4.0.0) lib/rails/commands.rb:78:in `block in <top (required)>'
railties (4.0.0) lib/rails/commands.rb:73:in `tap'
railties (4.0.0) lib/rails/commands.rb:73:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'

@iHiD
Copy link

iHiD commented Jul 29, 2013

I'm thinking the error is maybe coming from this line in orm_adapter which could call order will no params unless an order is passed into it? Maybe?

@iHiD
Copy link

iHiD commented Aug 7, 2013

Any thoughts on this, @josevalim? This is a really barebones app, so I'm not sure how I've broken it :)

@josevalim
Copy link
Contributor

@iHiD you are correct. if this is causing an issue, it should be solved in ORM Adapter, as first was supposed to be handled transparently by the adapter. :)

@iHiD
Copy link

iHiD commented Aug 8, 2013

@josevalim OK - cool. I'll check that out tomorrow and work a PR. Any ideas why I'm seeing it but presumably everyone else isn't? Thanks :)

@nashby
Copy link
Collaborator

nashby commented Aug 8, 2013

@iHiD remove this String extension and everything should work fine.

Since this code adds to_a method splat operator (*) starts to work incorrectly https://github.com/rubyspec/rubyspec/blob/master/language/splat_spec.rb#L51

@iHiD
Copy link

iHiD commented Aug 12, 2013

Thanks @nashby. For anyone else coming to this, Vasiliy has written a great blog post about this.

@nashby
Copy link
Collaborator

nashby commented Aug 12, 2013

@iHiD ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants