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

NoMethodError: undefined method `model_class=' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x759862a2> #32

Open
fadyZohdy opened this issue Jan 1, 2019 · 5 comments

Comments

@fadyZohdy
Copy link

i am trying to upgrade to rails 5.2 using fresh_connection 3.0.2 but am getting this stack trace when starting the app in any mode

NoMethodError: undefined method `model_class=' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x759862a2>
                              connection at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/fresh_connection-3.0.2/lib/fresh_connection/extend/ar_base.rb:21
                                     tap at org/jruby/RubyKernel.java:1878
                              connection at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/fresh_connection-3.0.2/lib/fresh_connection/extend/ar_base.rb:21
                           table_exists? at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activerecord-5.2.2/lib/active_record/model_schema.rb:324
            tokens_has_json_column_type? at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/devise_token_auth-1.0.0/app/models/devise_token_auth/concerns/user.rb:108
                                    User at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/devise_token_auth-1.0.0/app/models/devise_token_auth/concerns/user.rb:26
                             module_eval at org/jruby/RubyModule.java:3036
                         append_features at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/concern.rb:122
                                 include at org/jruby/RubyModule.java:2802
                            <class:User> at /Users/fady/workspace/optima/BulkWhiz_commons/BulkWhiz/app/models/user.rb:97
                                  <main> at /Users/fady/workspace/optima/BulkWhiz_commons/BulkWhiz/app/models/user.rb:4
                                    load at org/jruby/RubyKernel.java:1000
                                  (root) at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:1
                               load_file at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:476
                        new_constants_in at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:661
                               load_file at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:475
                         require_or_load at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:373
                          load_interlock at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:37
                                 loading at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:14
                               exclusive at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/concurrency/share_lock.rb:151
                                 loading at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:13
                          load_interlock at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:37
                         require_or_load at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:356
                   load_missing_constant at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:510
                               const_get at org/jruby/RubyModule.java:3479
                           const_missing at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:195
                                    each at org/jruby/RubyArray.java:1789
                                  inject at org/jruby/RubyEnumerable.java:1047
                             constantize at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/inflector/methods.rb:283
                             constantize at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/inflector/methods.rb:281
                                     get at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:582
                             constantize at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:613
                                     get at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/devise-4.5.0/lib/devise.rb:316
                                      to at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/devise-4.5.0/lib/devise/mapping.rb:83
                                 modules at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/devise-4.5.0/lib/devise/mapping.rb:78
                                  routes at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/devise-4.5.0/lib/devise/mapping.rb:95
                      default_used_route at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/devise-4.5.0/lib/devise/mapping.rb:162
                              initialize at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/devise-4.5.0/lib/devise/mapping.rb:72
                             add_mapping at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/devise-4.5.0/lib/devise.rb:346
                                    each at org/jruby/RubyArray.java:1789
                              devise_for at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/devise-4.5.0/lib/devise/rails/routes.rb:243
                              devise_for at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/devise-4.5.0/lib/devise/rails/routes.rb:242
             mount_devise_token_auth_for at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/devise_token_auth-1.0.0/lib/devise_token_auth/rails/routes.rb:30
                           instance_exec at org/jruby/RubyBasicObject.java:2666
                                  <main> at /Users/fady/workspace/optima/BulkWhiz_commons/BulkWhiz/config/routes.rb:5
                              eval_block at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:432
                                  <main> at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/actionpack-5.2.2/lib/action_dispatch/routing/route_set.rb:414
                                    load at org/jruby/RubyKernel.java:1007
                                  <main> at /Users/fady/workspace/optima/BulkWhiz_commons/BulkWhiz/config/routes.rb:1
                                  (root) at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:1
                                    load at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285
                         load_dependency at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257
                                    each at org/jruby/RubyArray.java:1789
                                    load at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285
                              load_paths at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41
                              load_paths at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41
                                 reload! at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:20
                                 updater at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:30
                                 execute at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/activesupport-5.2.2/lib/active_support/file_update_checker.rb:83
                           instance_exec at org/jruby/RubyBasicObject.java:2666
                                 execute at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:10
                                Finisher at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/application/finisher.rb:130
                                     run at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/initializable.rb:32
                        run_initializers at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/initializable.rb:61
                              tsort_each at /Users/fady/.rvm/rubies/jruby-9.2.4.0/lib/ruby/stdlib/tsort.rb:228
       each_strongly_connected_component at /Users/fady/.rvm/rubies/jruby-9.2.4.0/lib/ruby/stdlib/tsort.rb:350
                                    each at org/jruby/RubyArray.java:1789
                                    call at org/jruby/RubyMethod.java:129
  each_strongly_connected_component_from at /Users/fady/.rvm/rubies/jruby-9.2.4.0/lib/ruby/stdlib/tsort.rb:431
       each_strongly_connected_component at /Users/fady/.rvm/rubies/jruby-9.2.4.0/lib/ruby/stdlib/tsort.rb:349
       each_strongly_connected_component at /Users/fady/.rvm/rubies/jruby-9.2.4.0/lib/ruby/stdlib/tsort.rb:347
                              tsort_each at /Users/fady/.rvm/rubies/jruby-9.2.4.0/lib/ruby/stdlib/tsort.rb:226
                              tsort_each at /Users/fady/.rvm/rubies/jruby-9.2.4.0/lib/ruby/stdlib/tsort.rb:205
                                  <main> at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/initializable.rb:60
                                 require at org/jruby/RubyKernel.java:976
                             initialize! at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/application.rb:361
                                  <main> at /Users/fady/workspace/optima/BulkWhiz_commons/BulkWhiz/config/environment.rb:6
                           instance_eval at org/jruby/RubyBasicObject.java:2594
                                  (root) at uri:classloader:/jruby/kernel/kernel.rb:1
                        require_relative at uri:classloader:/jruby/kernel/kernel.rb:13
                                    eval at org/jruby/RubyKernel.java:1043
                         new_from_string at config.ru:3
                              initialize at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/rack-2.0.6/lib/rack/builder.rb:55
                         new_from_string at config.ru:1
                         new_from_string at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/rack-2.0.6/lib/rack/builder.rb:49
                              parse_file at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/rack-2.0.6/lib/rack/builder.rb:40
       build_app_and_options_from_config at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/rack-2.0.6/lib/rack/server.rb:319
                                     app at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/rack-2.0.6/lib/rack/server.rb:219
                                     app at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:27
                             wrapped_app at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/rack-2.0.6/lib/rack/server.rb:354
                                     tap at org/jruby/RubyKernel.java:1878
                           log_to_stdout at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:89
                                   start at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:51
                                 perform at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:147
                                 perform at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/commands/server/server_command.rb:142
                                     run at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/thor-0.20.3/lib/thor/command.rb:27
                          invoke_command at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/thor-0.20.3/lib/thor/invocation.rb:126
                                  <main> at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/thor-0.20.3/lib/thor.rb:387
                                 require at org/jruby/RubyKernel.java:976
                                  <main> at /Users/fady/.rvm/gems/jruby-9.2.4.0/gems/railties-5.2.2/lib/rails/command/base.rb:65

any help would be appreciated 🙏

@tsukasaoishi
Copy link
Owner

Thank you for your issue.
I’m in a holiday. Please wait a while.
I will address this issue when I come back home.

@fadyZohdy
Copy link
Author

great thank you.

@tsukasaoishi
Copy link
Owner

I fixed this issue.
Could you please try version 3.0.3 ?

@fadyZohdy
Copy link
Author

Thank you for the quick response 🙏
but the problem still persists.
configuring the database.yml then requiring 'fresh_connection' after project initialization and then doing any query against the db causes the issue.
are we doing anything wrong ?

@tsukasaoishi
Copy link
Owner

Maybe there is still information I do not know.
Could you give me the following information after using ver 3.0.3?
Please be careful to mask your sensitive information.

  • Back trace at exception occurrence
  • Contents of config/database.yml
  • Content of Gemfile

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

No branches or pull requests

2 participants