Search code examples
ruby-on-railsrubyfreetdsacts-as-audited

How can I debug a gem in Rails?


I'm attempting to start my rails server, but I'm getting the error trace below.

I've commented out the line mentioned here:

4.2.0/lib/audited/auditor.rb:48:in `audited'
    from /home/david-vm/Documents/rails_projects/bane/app/models/user.rb:9:in `<class:User>'

, and I can get it to run, but I'm not sure why that is breaking it. So I was thinking of maybe using byebug to trace down the issue, but can't seem to figure out how I would go about that. Or is there another way I can troubleshoot this issue? Thanks!

Error

/home/david-vm/.rvm/gems/ruby-2.3.0/gems/tiny_tds-0.7.0/lib/tiny_tds/client.rb:74:in `connect': Server name not found in configuration files (TinyTds::Error)
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/tiny_tds-0.7.0/lib/tiny_tds/client.rb:74:in `initialize'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-sqlserver-adapter-4.2.3/lib/active_record/connection_adapters/sqlserver_adapter.rb:280:in `new'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-sqlserver-adapter-4.2.3/lib/active_record/connection_adapters/sqlserver_adapter.rb:280:in `dblib_connect'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-sqlserver-adapter-4.2.3/lib/active_record/connection_adapters/sqlserver_adapter.rb:271:in `connect'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-sqlserver-adapter-4.2.3/lib/active_record/connection_adapters/sqlserver_adapter.rb:59:in `initialize'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-sqlserver-adapter-4.2.3/lib/active_record/sqlserver_base.rb:18:in `new'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-sqlserver-adapter-4.2.3/lib/active_record/sqlserver_base.rb:18:in `sqlserver_connection'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
from /home/david-vm/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
from /home/david-vm/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:87:in `connection'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/model_schema.rb:230:in `table_exists?'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/primary_key.rb:97:in `get_primary_key'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/primary_key.rb:85:in `reset_primary_key'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.0/lib/active_record/attribute_methods/primary_key.rb:73:in `primary_key'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/audited-activerecord-4.2.0/lib/audited/adapters/active_record.rb:7:in `default_ignored_attributes'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/audited-4.2.0/lib/audited/auditor.rb:48:in `audited'
from /home/david-vm/Documents/rails_projects/bane/app/models/user.rb:9:in `<class:User>'
from /home/david-vm/Documents/rails_projects/bane/app/models/user.rb:1:in `<top (required)>'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:457:in `load'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:457:in `block in load_file'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:647:in `new_constants_in'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:456:in `load_file'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:354:in `require_or_load'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:494:in `load_missing_constant'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:184:in `const_missing'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/inflector/methods.rb:261:in `const_get'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/inflector/methods.rb:261:in `block in constantize'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/inflector/methods.rb:259:in `each'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/inflector/methods.rb:259:in `inject'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/inflector/methods.rb:259:in `constantize'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:566:in `get'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:597:in `constantize'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/devise-4.0.1/lib/devise.rb:377:in `get'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/devise-4.0.1/lib/devise/mapping.rb:81:in `to'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/devise-4.0.1/lib/devise/mapping.rb:76:in `modules'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/devise-4.0.1/lib/devise/mapping.rb:93:in `routes'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/devise-4.0.1/lib/devise/mapping.rb:160:in `default_used_route'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/devise-4.0.1/lib/devise/mapping.rb:70:in `initialize'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/devise-4.0.1/lib/devise.rb:411:in `new'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/devise-4.0.1/lib/devise.rb:411:in `add_mapping'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/devise-4.0.1/lib/devise/rails/routes.rb:241:in `block in devise_for'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/devise-4.0.1/lib/devise/rails/routes.rb:240:in `each'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/devise-4.0.1/lib/devise/rails/routes.rb:240:in `devise_for'
from /home/david-vm/Documents/rails_projects/bane/config/routes.rb:11:in `block in <top (required)>'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:423:in `instance_exec'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:423:in `eval_block'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/actionpack-4.2.0/lib/action_dispatch/routing/route_set.rb:401:in `draw'
from /home/david-vm/Documents/rails_projects/bane/config/routes.rb:1:in `<top (required)>'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/application/routes_reloader.rb:40:in `each'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/file_update_checker.rb:75:in `execute'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/application/routes_reloader.rb:27:in `updater'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/david-vm/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /home/david-vm/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /home/david-vm/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /home/david-vm/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /home/david-vm/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /home/david-vm/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /home/david-vm/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from /home/david-vm/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /home/david-vm/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!'
from /home/david-vm/Documents/rails_projects/bane/config/environment.rb:5:in `<top (required)>'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/application.rb:328:in `require_environment!'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:142:in `require_application_and_environment!'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:67:in `console'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/david-vm/.rvm/gems/ruby-2.3.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

User.rb

   class User < ActiveRecord::Base
      # Include default devise modules. Others available are:
      # :confirmable, :lockable, :timeoutable and :omniauthable
      devise :ldap_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
      after_destroy :ensure_an_admin_remains
      before_create { generate_token(:auth_token) }

      # Audit changes made except for the columns as specified below
      audited except: [:last_seen_at, :sign_in_count, :last_sign_in_at, :last_sign_in_ip, :password_digest]
      has_associated_audits

      acts_as_tagger
      acts_as_taggable_on :roles

    # associations, methods, etc...

    end

Update

Turns out it was a DNS issue, so even though my database.yml hadn't changed- the server name was no longer working. Just added the update in case anyone is having this similar issue, might be worth checking this out.


Solution

  • The answer is IN the stack trace. It's telling you exactly what file ON your system is having the error. The fact that that file came from a gem, or lives in a different part of your computer, is irrelevant.

    /home/david-vm/.rvm/gems/ruby-2.3.0/gems/tiny_tds-0.7.0/lib/tiny_tds/client.rb:74:in `connect': Server name not found in configuration files (TinyTds::Error)

    Open that file (or whatever file in the backtrace seems most appropriate) with your editor, stick a binding.pry (or byebug, or debugger, whatever you're using) in there before the line it's blowing up on (74). Then restart your app and debug as if it was a file in your app.