2013-02-22 32 views
1

嗨,所以我偶然發現了一種新的方式來要求我的紅寶石的寶石在我的末日應用程序使用捆綁,我想知道,如果這是我應該怎麼做:這是需要紅寶石的正確方法嗎?

我的寶石文件看起來像:

source 'https://rubygems.org' 
gem 'sinatra' 
gem 'thin' 
gem 'haml' 

我config.ru文件看起來像:

require 'rubygems' 
require 'bundler' 

Bundler.require 

require './web' 
run Sinatra::Application 

我web.rb文件看起來像:

class MyApp 
    before do 
    cache_control :public, :max_age => 60 
    end 

    not_found do 
    haml :not_found 
    end 

    get '/' do 
    haml :index 
    end 
end 

回答

1

從你config.ru文件擺脫這些行:

require 'rubygems' 
require 'bundler' 

Bundler.require 

只要確保你從終端運行

bundle install 

啓動應用程序之前安裝你的寶石。

+0

嗨,感謝您的建議,此應用程序在heroku上運行,並且我在將它推送到git存儲庫之前在我的mac上運行軟件包安裝,因爲heroku需要Gemfile.lock。 – 2013-02-22 23:39:27

+0

每次添加gem並在本地重新啓動時,應該運行bundle install。 – 2013-02-22 23:49:44

+0

是的,這就是我做的,但是當它運行在服務器上時,我將無法運行捆綁包安裝,因此我爲什麼要詢問上述代碼 – 2013-02-22 23:54:40