开发者

require in capistrano deploy.rb cannot find file

开发者 https://www.devze.com 2023-02-18 17:31 出处:网络
I have a rails 3.0.5 app and I\'m setting up capistrano to use a recipe. in my config directory I have a file named \"database_capistrano.rb\" and in my deploy.rb, also in config directory, I have th

I have a rails 3.0.5 app and I'm setting up capistrano to use a recipe.

in my config directory I have a file named "database_capistrano.rb" and in my deploy.rb, also in config directory, I have the following line, just in the beginning:

require 'database_capistrano'

But I'm getting:

`require': no such file to开发者_开发问答 load -- capistrano_database (LoadError)

Also try with:

require 'database_capistrano.rb'

And don't work...

How, in Rails 3.0.5, include files in capistrano deploy.rb??


Ok, I manage to find out how this should be done.

Just copied the file to a new sub-directory "deploy", for organization only, and at the beginning of my deploy.rb, added:

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'deploy')

Then, in deploy.rb, just used:

require 'database_capistrano'


For future visitors, I got better results with the answer found in Capistrano: deploy.rb file refactoring

i.e instead of require, use load. As long as that file is a gem in the bundle or a file that requires other gems that are in bundle, this will work.

To be frank, I didn't try the accepted answer, half because it looked a little workaround-ish, and half because I didnt fully understand how to adapt it for my situation

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号