
RAILS_ENV =生产包exec rake资产:预编译预编译我的资产.
app / assets目录的所有文件都编译为public / assets
application.CSS编译为application-7a23a105125768e41d9d24aee4553615.CSS.
我的控制器代码是:
kit = imgKit.new(render_to_string(:partial => 'form',:height => 200,:transparent => true,:quality => 10,:layout => false,:locals => {:project => @project})) # t = kit.to_img(:png) kit.stylesheets << "#{Rails.root.to_s}/public/assets/application.CSS" #file = kit.to_file(Rails.root + "public/pngs/" + "screenshot.png") file = kit.to_file(Rails.root + "public/assets/" + "screenshot.png") #send_file("#{Rails.root.to_s}/public/pngs/screenshot.png",:filename => "screenshot.png",:type => "image/png",:disposition => 'attachment',:streaming=> 'true') 我不知道如何解决/public/assets/application.CSS未找到错误…
没有这样的文件或目录 – public / assets / application.CSS
我使用https://github.com/csquared/IMGKit/issues/36来获取CSS并在我的快照中工作
编辑
def update#@kit = imgKit.new(render_to_string,wIDth: 480,height: 800,:quality => 100) respond_to do |format| if @project.update(project_params) kit = imgKit.new(render_to_string(:partial => 'form',:locals => {:project => @project})) # t = kit.to_img(:png) kit.stylesheets << "self.class.helpers.asset_path('application.CSS')" #file = kit.to_file(Rails.root + "public/pngs/" + "screenshot.png") file = kit.to_file(Rails.root + "public/assets/" + "screenshot.png") #send_file("#{Rails.root.to_s}/public/pngs/screenshot.png",:streaming=> 'true') format.HTML { redirect_to root_path,notice: 'Flyer was successfully updated.' } format.Json { render :show,status: :ok,locatioFlyern: @project } else format.HTML { render :edit } format.Json { render Json: @project.errors,status: :unprocessable_entity } end endend解决方法 您可以使用Sprockets :: Rails :: Helper#asset_digest_path,找到 here.由于您在控制器中,因此您可以访问它 self.class.helpers.asset_digest_path('application.CSS')# => "application-7a23a105125768e41d9d24aee4553615.CSS" 同样,asset_path将生成application.CSS文件的路径
self.class.helpers.asset_path('application.CSS')# => "/assets/application-7a23a105125768e41d9d24aee4553615.CSS" 总结 以上是内存溢出为你收集整理的ruby-on-rails – 如何在生产轨道中提供指纹css路径4全部内容,希望文章能够帮你解决ruby-on-rails – 如何在生产轨道中提供指纹css路径4所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)