5

I have a Rails Engine I'm working on and the gemspec has this:

s.add_development_dependency "rspec-rails"
s.add_development_dependency "combustion"
s.add_development_dependency "capybara"
s.add_development_dependency "factory_girl_rails"
s.add_development_dependency "ffaker"
s.add_development_dependency "draper"
s.add_runtime_dependency "sqlite3"
s.add_runtime_dependency "slim-rails"
s.add_runtime_dependency "sass-rails"
s.add_runtime_dependency "jquery-rails"
s.add_runtime_dependency "rails", "~> 3.2"

However upon going to the correct controller/action I get this error:

Missing template countdown/subscriptions/index, countdown/application/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in: * "/Users/krainboltgreene/Repository/ruby/countdown/spec/dummy/app/views" * "/Users/krainboltgreene/Repository/ruby/countdown/app/views"

Notice the handlers part?

tshepang
  • 12,111
  • 21
  • 91
  • 136
krainboltgreene
  • 1,841
  • 2
  • 17
  • 25

2 Answers2

10

You should require the gem in lib/your_engine.rb. If you only require it in your dummy app's config/application.rb, then others are going to have this same problem when include your engine in their apps.

This can be especially confusing because in regular Rails app development. It's easy to rely on Bundler.require to load all of your gems for you.

Reference: 5 Reasons to Avoid Bundler.require

double-beep
  • 5,031
  • 17
  • 33
  • 41
5

I had a similar problem with the dummy application not loading Devise. What I had to do was require it inside config/application.rb and then it worked. Perhaps you just need to require 'slim' there and it will work too?

Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
  • We talking `spec|test/dummy/config` or `config/`? I'll try both of course, but having it here would help others. – krainboltgreene Jan 31 '12 at 02:00
  • `spec|test/dummy/config`. An engine has no `config/application.rb`... because it's an engine! :) – Ryan Bigg Feb 01 '12 at 00:33
  • This answer explains the problem but doesn't provide the correct approach/solution. [Hannah's](http://stackoverflow.com/users/2048318/hannah-christine-deffenbaugh) suggestion that we should require the gem in `lib/your_engine.rb` is the right solution. – King'ori Maina Oct 09 '14 at 14:03