Skip to content
This repository was archived by the owner on May 17, 2026. It is now read-only.

HykuAddons: Debugging

Paul Danelli edited this page Mar 3, 2022 · 1 revision

Debugging

Byebug

The byebug gem is included in development, but because of how Docker handles its processes, you must start the application in a specific way in order to have a request stop at your breakpoint.

docker-compose up -d; docker attach hyku_addons_web_1;

Now when you add byebug to your files, you will see the prompt in your webserver logs.

Finding a method

Because of the complexity and separation of concerns within the Engines and Gems, and because of the number of overrides that HykuAddons includes, it is important to check exactly where the method you are calling resides.

For example, HykuBase overrides the Account#switch! method, which is normally found here:

# Original switch! method
  def switch!
    solr_endpoint.switch!
    fcrepo_endpoint.switch!
    redis_endpoint.switch!
  end

If you login to your console, you can find exactly where the active version of the method is:

2.7.4 :015 > Account.first.method(:switch!)
 => #<Method: Account(id: integer, tenant: string, cname: string, created_at: datetime, updated_at: datetime, solr_endpoint_id: integer, fcrepo_endpoint_id: integer, name: string, redis_endpoint_id: integer, datacite_endpoint_id: integer, settings: jsonb, data: jsonb, frontend_url: string, search_only: boolean)#switch!() /home/app/app/models/concerns/hyku_addons/account_behavior.rb:66>

We can see where the method is defined and if we want to see the code, we could do the following:

2.7.4 :016 > puts Account.first.method(:switch!).source
  def switch!
    solr_endpoint.switch!
    fcrepo_endpoint.switch!
    redis_endpoint.switch!
    datacite_endpoint.switch!
    Settings.switch!(name: locale_name, settings: settings)
    switch_host!(cname)
    setup_tenant_cache(cache_api?)
    switch_hyrax_orcid_credentials!
  end

Using the method method and the methods method will help you track down where and how overrides are being included and which methods are contained on each class.

Clone this wiki locally