我正在研究一个由三个不同应用程序组成的项目。 他们应该共享一些模型和外部布局。 为了避免代码重复, 我试图将应用程序布局( project_ name/ app/views/layouts/ application.html. haml
) 提取成宝石 。
我遵循了这些步骤:
- create the base gem structure with
bundle gem common
- place the layout file inside
common/app/views/layouts/application.html.haml
写着Gemspec 描述符
# -*- encoding: utf-8 -*- require File.expand_path( ../lib/common/version , __FILE__) Gem::Specification.new do |gem| gem.authors = ["Arthur Alkmim"] gem.email = ["myemail@here"] gem.description = %q{Common project files} gem.summary = %q{Common project files, including layout and migrations} gem.homepage = "" gem.files = `git ls-files`.split($) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.name = "common" gem.require_paths = ["lib"] gem.version = Common::VERSION end
承诺修改
gem build common.gemspec
(successful)rake install
(successful)- Place
gem common
in the project Gemfile
但工程仍然无法加载应用程序布局。 我该怎么做才能告诉我的工程, 它必须通过宝石装入布局文件?
提前感谢。