How does one reference compiled assets from the controller in Rails 3.1?

后端 未结 6 1372
鱼传尺愫
鱼传尺愫 2020-12-09 03:50

I\'m using the PDFkit in my controller to build out a series of PDFs, zip them up, and then send them to the user.

In order to control the output styles, I tell PDFK

6条回答
  •  被撕碎了的回忆
    2020-12-09 04:15

    The best way to get the compiled name is from the manifest that is generate when you compile.

    You can make a controller method that serves the raw name in development, and then accesses the manifest in production to map the correct name.

    The location of the manifest by default is:

    File.join(Rails.public_path, config.assets.prefix, 'manifest.yml')

    But it looks like you can access this as a hash at config.assets.digests

    config.assets.digests[css_file_name_as_string]

提交回复
热议问题