ruby - Gem dependencies in Rails Engines -


i have followed getting started engines in rails documentation , have set api engine in engines directory. according paragraph 6.6 other gem dependencies 1 supposed define gem dependencies in engines/my_api/my_api.gemspec file , pretty did:

s.add_dependency "responders", "2.0" 

after adding

`gem 'my_api', path: "engines/my_api"` 

to applications gemfile , running bundler, looks expected:

 bundle install | grep responders  installing responders 2.0.0 

in next step set root path corresponding controller etc. , go engines/my_api/app/controllers/my_api/application_controller.rb , add following content:

module myapi   class applicationcontroller < actioncontroller::base     respond_to :json   end end 

i start rails server, go root url , guess what? following message:

the controller-level respond_to' feature has been extracted responders gem. add gemfile continue using feature: gem 'responders', '~> 2.0' consult rails upgrade guide details.

as suggested in error message, i've added gem applications gemfile, run bundle install , works expected.

as far understood, engines supposed self contained rails apps. self contained app @ least expect correctly resolve dependencies. assume doing wrong , hope able me tackle down problem, why have explicitly specify gem in applications gemfile?

edit:

forgot mention versions:

$ gem list | grep rails coffee-rails (4.1.0) jquery-rails (4.0.3) rails (4.2.1) rails-deprecated_sanitizer (1.0.3) rails-dom-testing (1.0.6) rails-html-sanitizer (1.0.2) sass-rails (5.0.3) sprockets-rails (2.2.4) 

as observe, gem included in bundle whether in application's gemfile or not. difference when bundler.require called during application initialisation auto requires gem's in application's gemfile - not indirect dependencies.

if gem requires responders gem gem loaded should require explicitly - example @ top of my_api.rb


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -