炼油厂 - 资产预编译refinery_patch失败

时间:2013-08-26 09:08:32

标签: ruby-on-rails refinerycms

能够将炼油厂整合到现有的rails应用程序中,但资产预编译失败并出现错误:

cannot load such file -- refinery_patch

application.rb包含代码:

config.autoload_paths += Dir["#{config.root}/lib/**/"] # to load files from lib directory, including subfolders

    config.before_initialize do
      require 'refinery_patch'
      require 'restrict_refinery_to_refinery_users'
    end

    include Refinery::Engine
    after_inclusion do
      [ApplicationController, ApplicationHelper].each do |c|
        c.send :include, ::RefineryPatch
      end

      ::Refinery::AdminController.send :include, ::RestrictRefineryToRefineryUsers
      ::Refinery::AdminController.send :before_filter, :restrict_refinery_to_refinery_users
    end

和refinery_patch文件保存在lib / refinery中

module RefineryPatch

  def self.included(base)
    base.send :helper_method, 
              :current_refinery_user, 
              :refinery_user_signed_in?, 
              :refinery_user? if base.respond_to? :helper_method
  end

  def current_refinery_user
    current_user
  end

  def refinery_user_signed_in?
    user_signed_in?
  end

  def refinery_user?
    refinery_user_signed_in? && current_refinery_user.has_role?(:refinery)
  end

  def authenticate_refinery_user!
    authenticate_user!
  end

  def store_location
    session[:return_to] = request.fullpath
  end

  def redirect_back_or_default(default)
    redirect_to(session[:return_to] || default)
    session[:return_to] = nil
  end
end

在config.autoload_paths告诉加载lib文件夹中的所有文件时,不确定为什么它无法加载文件

1 个答案:

答案 0 :(得分:0)

遇到同样的问题,在这里找到解决方案。

http://refinerycms.com/guides/heroku

您必须在config / application.rb

中设置以下内容
config.assets.initialize_on_precompile = true