我一直在想Ruby的一些内置方法的时间复杂性,特别是这两个方法.我认为我自己想出的最好的排列方法是Θ(n·n!),Ruby的内置表现更好吗?如果是这样,请帮助我了解他们的算法.
我正在使用 Sass::Engine 动态编译 css 文件,我需要将环境和加载路径传递给链轮。这在开发中工作得很好:
def compile_scss
view_context = ActionView::Base.new
environment = Rails.application.assets
# body and filename are instance variables created elsewhere
@compiled_file = Sass::Engine.new(body,
filename: filename,
syntax: :scss,
cache: false,
load_paths: environment.paths,
sprockets: {
context: view_context,
environment: environment
}).render
end
Run Code Online (Sandbox Code Playgroud)
但在生产中失败,因为Rails.application.assets是nil。生产中的等价物是什么?