2010-11-23 31 views

答えて

1

設定をファイルconfig/initializers/にすることができます。情報名(manifesto.rbなど)を使用してください。ただし、基本的な使い方で設定する必要はありません。あなたのGemfileファイルで

、追加:

gem 'manifesto' 

はその後、バンドルを経由してインストールします。

0123: config/routes.rbアドオンで

bundle install 

ファイルを作成app/controllers/manifest_controller.rb

class ManifestController < ApplicationController 
    def show 
    headers['Content-Type'] = 'text/cache-manifest' 
    render :text => Manifesto.cache, :layout => false 
    end 
end 

# change 
render :text => Manifesto.cache, :layout => false 
# to 
render :text => Manifesto.cache(:directory => './mobile', :compute_hash => false), :layout => false 

またはYAMLファイルと初期化子を使用します。

match '/manifest' => 'manifest#show' 
はあなたが好き Manifesto.cacheに直接オプションを渡すことができますあなたのアプリを再起動し、 http://localhost:3000/manifest

で結果を表示

config/manifesto.yamlファイル:

# directory is relative to Rails root 
directory: './mobile' 
compute_hash: false 

config/initializers/manifesto.rbファイル:

# Load the config file and convert keys from strings in symbols (the manifesto gem need symbolized options). 
MANIFESTO_CONFIG = YAML.load_file(Rails.root.join('config', 'manifesto.yml').to_s).inject({}){|config,(k,v)| config[k.to_sym] = v; config} 

などManifesto.cacheにロードされた設定を渡す:

# change 
render :text => Manifesto.cache, :layout => false 
# to 
render :text => Manifesto.cache(MANIFESTO_CONFIG), :layout => false 
+0

が格好良い、ありがとう! manifesto.rbファイルに正確に何を入れますか? –

+0

@Jonathan Clark - 設定ファイルは必要ありません(manifesto.rbファイルは必要ありません)。 – Sinetris

+0

しかし、どのフォルダを使用するかはどこで選択しますか? –

関連する問題