How do I debug 3 gem rails?

I created a gem / engine based on this tutorial:

http://www.themodestrubyist.com/2010/03/05/rails-3-plugins---part-2---writing-an-engine/

However, I get an error when trying to use the gem in a newly created application. When I try to access the application, I get a "Routing error - undefined method` sub" for nil: NilClass.

The only thing I see in the log file is the same error. There is no trace trace / debug trace, so it’s hard to understand where the error comes from. Ideally, I would like to see a "gem" stack trace, but it doesn't seem that the rails are debugging errors coming from outside the application?

I am using rvm, ruby ​​1.9.2, rails 3.0.1.

Here is my config / routes.rb file from the pearl, although I don't think this is a routing error, as the debug message says.

Rails.application.routes.draw do resources :pictures, :controller => 'morph/pictures' end 

Any suggestions?

+4
source share
2 answers

If you uncomment

 Rails.backtrace_cleaner.remove_silencers! 

in config/initializers/backtrace_silencers.rb it will display a more complete stack. It worked for me.

+14
source

Is there a backtrace in the console?

If you cannot find any additional output, you can place the β€œdebugger” instruction somewhere near the start of your application and go through the source code until an error occurs.

You can do the same with the gem / plugin source.

Edit: the author seems to have a link to the demo code at the bottom of the article. It may also be helpful.

+2
source

Source: https://habr.com/ru/post/1339838/


All Articles