我目前正在开发一个Rails应用程序,该应用程序可以用作另一个Rails应用程序的更新程序。
我正在执行更新程序,
我在最后一步有问题。
当我跑步时:
Dir.chdir('../other-project')
`bundle exec rails server -d -p 3000`
从更新程序应用程序看来,它是从更新程序捆绑软件中提取的,而不是它应从中提取的新应用程序捆绑软件中提取的。
更新器是用Rails 4编写的,正在更新的应用程序是Rails 3。
当我尝试启动服务器时,得到以下信息:
/home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `handlebars' for #<Rails::Application::Configuration:0x007f9de18de100> (NoMethodError)
from /home/vagrant/apps/other-project/config/application.rb:22:in `<class:Application>'
from /home/vagrant/apps/other-project>'
from /home/vagrant/apps/other-project/config/application.rb:13:in `<top (required)>'
from /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:79:in `require'
from /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:79:in `block in server'
from /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:76:in `tap'
from /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:76:in `server'
from /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /home/vagrant/.rbenv/versions/2.0.0-p481/lib/ruby/gems/2.0.0/gems/railties-4.1.4/lib/rails/commands.rb:17:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
从此输出中,我可以看出它正在尝试使用错误版本的Railties ...
当我手动cd ../other-project
,bundle exec rails server -d -p 3000
它工作正常。
有什么bash技巧可以用来解决这个问题吗?基本框是Ubuntu 14.04
谢谢!
好吧,我已经花了整整一个上午的时间进行故障排除,并且找到了解决方案!
您所要做的只是在以下位置设置BUNDLE_GEMFILE环境变量:
bundle exec rails server -d -p 3000
似乎Bundler需要一些帮助来找到项目Gemfile,因为我正在尝试在当前包中启动另一个应用程序,这是我创建的用于控制此更新程序将负责更新的应用程序的类。
我很高兴地说start方法终于按预期工作了!
class AppController
@dir = Rails.root.join('../', 'Other-app/')
def self.running?
File.exist?("#{@dir}/tmp/pids/server.pid")
end
def self.start
if running?
puts "app already running"
else
Dir.chdir(@dir)
puts "starting app..."
`BUNDLE_GEMFILE=Gemfile bundle exec rails server -d -p 3000`
puts "app started"
end
end
def self.kill
if not running?
puts "app already dead"
else
Dir.chdir(@dir)
puts "killing app..."
`kill $(cat tmp/pids/server.pid)`
puts "app dead"
end
end
def self.restart
if running?
kill
start
else
start
end
end
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句