私は3つの異なるアプリケーションで構成されるプロジェクトに取り組んでいます。彼らはいくつかのモデルと外側のレイアウトを共有することになっています。project_name/app/views/layouts/application.html.haml
コードの重複を避けるために、アプリケーションのレイアウト( )をgemに抽出しようとしています。
私はこれらの手順に従いました:
- でベースgem構造を作成します
bundle gem common
- レイアウトファイルを内部に配置します
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
(成功)rake install
(成功)gem 'common'
プロジェクトGemfileに配置します
ただし、それでもプロジェクトはアプリケーションレイアウトをロードしません。プロジェクトにgemを介してレイアウトファイルをロードする必要があることを伝えるにはどうすればよいですか?
前もって感謝します。