rails 3.1 Engines Gemspec and config initializers
-
26-10-2019 - |
Question
I am developing an rails 3.1 mountable engine. Build the engine very well and mounted it on a sub-domain. Now what i am having issue is that, in my engine
Gemfile
i specified a gem:
gem "show_for", "~> 0.2.4"
also in .gemspec
file
s.add_dependency "show_for", "~> 0.2.4"
then i used engine's script/rails g show_for:install
and it created a initializer file
in config/initilizers directory.
When i go to main_app
and run bundle install
it shows that gem in the list. But when i start the application it show the error:
path_to_my_engine/config/initializers/show_for.rb:2:in `<top (required)>': uninitialized constant ShowFor (NameError)
How can we resolve this issue?
Solution
You might have to add: require 'show_for' at the top of your engine.rb file. I had a similar issue with my engine.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow