Invoking an external rake task from Rails: dependency issues

I am currently developing a standalone ruby ​​application along with a Rails application that works as its interface. I manage the dependencies of a Ruby application with the Bundler, so there are two gemfiles.

I have a problem trying to run a Ruby application from the Rails interface using a system call to the rake command.

When I call the rake task from the standard IRB, it works; but if I try to invoke a task from the Rails controller or the rails console, there are dependency issues.

As a workaround, I can add all the gems that are missing in the Rails application to Gemfile Rails, but I assume this approach is wrong.

I think this may be a problem with the coverage of the Bundler. How could I get around this?

Thank.

+3
source share
1 answer
fork do
  Dir.chdir("/your/project/dir")
  ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', __FILE__)
  Bundler.setup
  exec "rake -T"
end
+2
source

All Articles