2016-03-22 14 views
0

私はタイトルコードが繰り返しているので、エンジンに入れてすべてのアプリケーションにロードすることにしました。Railsエンジンヘルパーファイル(作業中でも)ロードされていません

(engine.rbの回避策を使用していても)ヘルパーの読み込みに問題があります。

ホストアプリケーションがnomethodエラーを表示していますが、ヘルパーファイルがロードされていないと思います。私はまた、エンジンからのビューをレンダリングすることもできますが、まだヘルパーは私が行方不明の何かがロードされません?

メインブロックの問題を引き起こすコードブロック。

<h1><%= yield(:phc_title) %></h1> 
<span><%= yield(:phc_title_tagline) %></span> 
<ol class="breadcrumb"> 
    <li><a href="#">Home</a></li> 
</ol> 

/lib/phctitler/engine.rb

module Phctitler 
    class Engine < ::Rails::Engine 

     # Required Dependencies 
     require 'figaro' 

     # Isolate Namespace for PHC Members 
     isolate_namespace Phctitler 

     # Testing Generator 
     config.generators do |g| 
      g.test_framework :rspec, 
      fixtures: true, 
      view_specs: false, 
      helper_specs: false, 
      routing_specs: false, 
      controller_specs: true, 
      request_specs: false 
      g.fixture_replacement :factory_girl, dir: "spec/factories" 
     end 

     # Load Helper Files 
     config.to_prepare do 
      ApplicationController.helper(Phctitler::ApplicationHelper) 
     end 

     # Auto Mount Plugin 
     initializer "phctitler", before: :load_config_initializers do |app| 
      Rails.application.routes.append do 
       mount Phctitler::Engine, at: "/" 
      end 
     end 

    end 
end 

ヘルパー/ phctitler/application_helper.rb

module Phctitler 
    module ApplicationHelper 

    # Helper for Page Title 
     def phc_title(phc_page_title) 
      content_for :phc_title, phc_page_title.to_s 
     end 

     # Helper for Page Title Tag 
     def phc_title_tagline(phc_page_title_tagline) 
      content_for :phc_title_tagline, phc_page_title_tagline.to_s 
     end 

    end 
end 
+0

1つのモジュールにフルブローエンジンを使用するのは少し難題ですか? – max

+0

そうですね、この方法で多くのアプリでアップデートを公開する方が簡単です。また、キーワードとSEOのヘルプヘルパーを追加することも検討します。 – bradpotts

答えて

0

これが働いていました。

以下の行をホストアプリケーションのコントローラに入れます。

helper Phctitler::Engine.helpers 
関連する問題