Rails Engine - Gems dependencies, how to load them into the application?

后端 未结 7 1060
Happy的楠姐
Happy的楠姐 2020-11-30 01:23

I\'m doing an engine here, it works alright in stand alone.

When I transform it into a gem, and load it inside another application, I get a lot of undefined errors,

7条回答
  •  隐瞒了意图╮
    2020-11-30 02:22

    Include them in your gemfile and run bundle install. Then require them in your lib//engine.rb file. Don't forget to require rubygems

      require 'rubygems'
      require 'paperclip'
      require 'jquery-rails'
      require 'rails3-jquery-autocomplete'
      require 'remotipart'
      require 'cancan'
    

    Then in your host app (The app where you included your gem) run bundle install/ bundle update (bundle update did the trick for me) and then everything should work perfectly. You can also test this by starting the console in your host app and just type the module name e.g.

    Loading development environment (Rails 3.0.3)
    irb(main):001:0> Paperclip
    => Paperclip
    

    Hope this helps

提交回复
热议问题