1

能够将炼油厂集成到现有的 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

并且炼油厂补丁文件保存在 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 文件夹中的所有文件

4

1 回答 1

0

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

http://refinerycms.com/guides/heroku

您必须在 config/application.rb 中设置以下内容

config.assets.initialize_on_precompile = true
于 2013-09-27T23:32:25.817 回答