1

I'm developing a ruby gem with a Rails engine and railtie in it. I've made good progress but one of my biggest pain points is having to restart the Rails server every time I make a change to the gem for testing.

Gemfile

gem 'my_gem', :source => '~/apps/my_gem'

I've tried adding the path to the autoloads, with no success:

config/application.rb

config.autoload_paths += %W( ~/apps/my_gem )

I'm guessing the issue is that the Railtie in the gem is only loaded when the server starts. Is there a way to dynamically load my gem so that I don't have to keep restarting the server when I change some code?

1 Answer 1

2

Pretty sure you can use shotgun. It works with any rack server by reloading it with every new request. After you have install it, run the following command inside your rails app's directory:

$ shotgun

Pretty simple! Also, you can use it with Sinatra, like so:

$ shotgun my_website.rb

Hope this helps! :)

3
  • this looks promising, I'm going to give it a shot and report back. Feb 28, 2012 at 3:40
  • Alright, here's what I found, shotgun does what it says it does, it reloads the app on every request, which obviously slows things down. I can live with that, but now I'm missing the stack traces I need to debug. I tried the warn option, which gave lots of warnings, but still no stacktrace. I gave you a vote up, but this still isn't quite what I'm looking for. Thanks for your help! Feb 28, 2012 at 3:55
  • Hmm, that's odd. I use it regularly with Sinatra and it gives me perfect stack traces; I wonder why it's not working for you. Maybe it has something to do with rails... I'll look into this
    – Jwosty
    Feb 28, 2012 at 4:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.