Mik*_*rge 5 ruby-on-rails backticks ruby-on-rails-3 ruby-on-rails-4
我目前正在开发一个Rails应用程序,它作为另一个Rails应用程序的更新程序.
我有更新过程,
我在最后一步遇到了问题.
当我跑:
Dir.chdir('../other-project')
`bundle exec rails server -d -p 3000`
Run Code Online (Sandbox Code Playgroud)
从更新程序应用程序,它似乎是从更新程序包中提取而不是应该从中提取的新应用程序包.
更新程序是用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>'
Run Code Online (Sandbox Code Playgroud)
从这个输出我可以告诉它它正试图使用不正确版本的铁路...
当我手动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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
372 次 |
| 最近记录: |