0
我正在尝试使用称为Manifesto的宝石的HTML5清单函数。我坚持使用说明。我无法弄清楚这些设置应该放在哪里。使用Rails 3宝石宣言
任何想法?也许是更好的宝石?
https://github.com/johntopley/manifesto#readme
感谢所有帮助!
我正在尝试使用称为Manifesto的宝石的HTML5清单函数。我坚持使用说明。我无法弄清楚这些设置应该放在哪里。使用Rails 3宝石宣言
任何想法?也许是更好的宝石?
https://github.com/johntopley/manifesto#readme
感谢所有帮助!
你可以把你的设置放在config/initializers/
下的文件中。使用信息名称(如manifesto.rb
)。但是,您不需要具有基本用法的配置。
在你Gemfile
文件,添加:
gem 'manifesto'
然后通过捆绑安装:
bundle install
在config/routes.rb
添加创建文件app/controllers/manifest_controller.rb
class ManifestController < ApplicationController
def show
headers['Content-Type'] = 'text/cache-manifest'
render :text => Manifesto.cache, :layout => false
end
end
:
match '/manifest' => 'manifest#show'
重新启动应用程序并查看结果在http://localhost:3000/manifest
您可以直接通过选项Manifesto.cache
,如:
# change
render :text => Manifesto.cache, :layout => false
# to
render :text => Manifesto.cache(:directory => './mobile', :compute_hash => false), :layout => false
或者使用一个YAML文件和初始化。
的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
看起来不错,谢谢!我把什么放在manifesto.rb文件中? – 2010-11-23 19:26:56