imgkit
을 사용하여 웹 페이지의 스냅 샷을 찍습니다. 실행 :프로덕션 레일에서 지문 CSS 경로를 제공하는 방법 4
RAILS_ENV=production bundle exec rake assets:precompile
내 자산을 사전 컴파일하려면.
app/assets
디렉토리의 모든 파일은 application-7a23a105125768e41d9d24aee4553615.css
로 컴파일 public/assets
application.css
로 컴파일됩니다.
내 컨트롤러 코드입니다 : 내가 ... /public/assets/application.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')
해당 파일이나 디렉토리 - 공공/자산 없습니다/application.css
내 스냅 샷에
편집을 CSS와 작업을 얻을 수 https://github.com/csquared/IMGKit/issues/36을 사용하고 있습니다 당신은 Sprockets::Rails::Helper#asset_digest_path
사용할 수 있습니다
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', :height => 200, :transparent => true, :quality => 10, :layout => false,: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", :filename => "screenshot.png", :type => "image/png",:disposition => 'attachment',: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
end
end
의 경로를 얻을 것인가? 개발에 어떤 영향도 미치지는 않을 것입니다. – matanco
https://github.com/csquared/IMGKit/issues/36에서 언급했듯이 미리 컴파일했습니다! –
누구든지 이걸 극복 할 수 있습니까 –