Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I debug a rails 3 gem?

I have 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 am getting an error when trying to use the gem in a newly created application. I am getting a "Routing Error - undefined method `sub' for nil:NilClass" when trying to access the application.

The only thing I can see in the log file is the same error. No stack trace/debug trace, so it is difficult to figure out where the error is coming from. Ideally I would like to get see the stack trace "from the gem", but it appears that rails does not debug errors originating from outside the application?

I'm using rvm, ruby 1.9.2, rails 3.0.1.

Here is my config/routes.rb file from the gem, although I do not think this is a routing error as the debug message suggests..

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

Any suggestions?

like image 568
Ole Brum Avatar asked Feb 15 '11 15:02

Ole Brum


1 Answers

If you uncomment

Rails.backtrace_cleaner.remove_silencers!

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

like image 197
Christophe Belpaire Avatar answered Oct 04 '22 01:10

Christophe Belpaire