我想在我正在处理的rails 3.2应用程序上添加源映射支持.据我所知,Sprockets不支持生成源映射,并且从其github页面看起来该功能计划为4.0.我正在使用Sprockets 2.2,我认为猴子修补是唯一的方法.主Sprockets模块下的模块处理可以访问js_compressor函数,该函数可以修补以生成单个文件的源映射.但是,当JS文件合并时,我不知道如何添加它.我使用Uglifier 2.4作为压缩器.
该项目混合了CoffeeScript,JS和EJS文件.所以,我认为这就是链轮将它们组合在一起的方式.首先,它会将Coffeescript和EJS转换为JS,然后使用js_compressor压缩单个文件,然后将它们连接成组.现在,由于组合到同一文件的多个文件的源映射是单个文件.因此,我需要稍微更改编译过程,并在连接完成后使js_compressor在文件上运行.那么,任何人都可以帮忙吗?甚至解释链轮编译过程和使用的模块以及所涉及的功能也会有很大帮助.我不关心目前为CoffeeScript代码制作源地图文件.即使映射到他们转换的JS文件也行.
此外,如果有一些宝石可以提供帮助,我想非常欢迎.
我有一个类似于活动记录结构的树,带有一个自引用对象 - 例如,该对象可以是同一类的另一个对象的父级或子级。我需要一种在代码中有效地映射此结构的方法。到目前为止,我一直在使用活动记录 ORM 在 ruby 中做它,它的效率非常低。
这是 pod.rb 模型的样子:
    has_many :pod_parents, class_name: "PodPod", dependent: :delete_all
    has_many :parents, through: :pod_parents, :foreign_key => 'parent_id', :source => 'parent'
    has_many :pod_children, class_name: "PodPod", :foreign_key => 'parent_id'
    has_many :children, through: :pod_children, :source => 'pod'
    scope :active, -> {
        where(pod_state: "active").where(pod_type: ["standard","readonly"])
    }
这是相关的数据库架构:
table "pods"
  t.string "intention"
  t.integer "user_id"
  t.string "slug"
  t.string "url_handle"
  t.index ["slug"], name: "index_pods_on_slug"
  t.index ["url_handle"], name: "index_pods_on_url_handle"
table "pod_pods"
  t.integer "parent_id"
  t.integer "pod_id"
  t.index ["parent_id", "pod_id"], name: "index_pod_pods_on_parent_id_and_pod_id", unique: true …