Skip to content

Instantly share code, notes, and snippets.

@cemeng
Created July 19, 2012 04:16
Show Gist options
  • Save cemeng/3140712 to your computer and use it in GitHub Desktop.
Save cemeng/3140712 to your computer and use it in GitHub Desktop.
Wicked PDF

Niggling issue on our scss file:

background-image: url("file://<%= Rails.application.assets.find_asset('company_logo_for_forms.png').pathname %>");

It'd be nice to implement a helper method on sass-rails to encapsulate that logic. Something like

Module Sass
  Module Rails
    Module Helpers
      def asset_full_path(asset_name)
        Rails.application.assets.find_asset(asset_name).try(:pathname) || ""
      end
    end
  end
end

Another issue, because we are sharing our html and pdf template, we had to do this:

<% if params[:format] && params[:format] == 'pdf' %>
  <%= wicked_pdf_stylesheet_link_tag "invoice_pdf" %>
  <%= wicked_pdf_javascript_include_tag "invoice" %>
<% else %>
  <%= javascript_include_tag "invoice" %>
  <%= stylesheet_link_tag "invoice" %>
<% end %>

Useful Links

http://snikt.net/rails/2012/04/26/wicked-pdf/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment