Ruby on rails 如何替代轨道中的链轮路径?

Ruby on rails 如何替代轨道中的链轮路径?,ruby-on-rails,ruby-on-rails-3,ruby-on-rails-3.1,asset-pipeline,sprockets,Ruby On Rails,Ruby On Rails 3,Ruby On Rails 3.1,Asset Pipeline,Sprockets,我试图覆盖链轮在Rails中生成的路径,特别是对于sass助手 我使用各种解决方案取得了一些成果: a) 覆盖视图中的图像标记辅助对象 b) 重写ActionView::AssetPath计算函数 c) 在Sass::Script::Functions中包括新模块 但感觉应该有一个比这更简单的方法。有好办法吗 装饰链轮路径?我这样做是因为我们有一些自定义的url和打包内容。因此,最后我在sprockets/context.rb中发现了这条消息 Custom asset_path helper i

我试图覆盖链轮在Rails中生成的路径,特别是对于sass助手

我使用各种解决方案取得了一些成果:

a) 覆盖视图中的图像标记辅助对象

b) 重写ActionView::AssetPath计算函数

c) 在Sass::Script::Functions中包括新模块

但感觉应该有一个比这更简单的方法。有好办法吗
装饰链轮路径?我这样做是因为我们有一些自定义的url和打包内容。

因此,最后我在sprockets/context.rb中发现了这条消息

Custom asset_path helper is not implemented
Extend your environment context with a custom method.

environment.context_class.class_eval do
  def asset_path(path, options = {})
  end
end
这似乎表明Rails.application.assets.context\u class.class\u eval 允许我更改asset_路径处理程序,但它似乎不起作用。我不确定这是否是我的错,因为我找不到任何这样的例子

目前,我想让它正常工作的方法是:

  ActionView::AssetPaths.class_eval do
    def compute_public_path(source, dir, options = {})
      my_transform(source)
    end
  end

  Sprockets::Helpers::RailsHelper::AssetPaths.class_eval do
    def compute_public_path(source, dir, options = {})
      my_transform(source)
    end
  end

  ActionView::Helpers::AssetTagHelper::AssetPaths.class_eval do
    def compute_public_path(source, dir, options = {})
      my_transform(source)
    end
  end
我想我不需要这三个,但我不确定。谁知道他们的链轮想对此发表评论