File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44< html >
55< head >
66< title > <%= yield ( :title ) %> </ title >
7- <% app_css_path = Rails . root . join ( 'app' , 'assets' , 'builds' , 'application.css' ) %>
8- <% css = File . exist? ( app_css_path ) ? File . read ( app_css_path ) : '' %>
7+ <%
8+ # Load CSS from both app/assets/builds (development) and public/assets (production/staging)
9+ css = ''
10+ candidates = [ ]
11+
12+ # Add CSS from app/assets/builds (development)
13+ candidates . concat ( Dir . glob ( Rails . root . join ( 'app' , 'assets' , 'builds' , '*.css' ) . to_s ) )
14+
15+ # Add CSS from public/assets (production/staging with fingerprinted names)
16+ candidates . concat ( Dir . glob ( Rails . root . join ( 'public' , 'assets' , 'application-*.css' ) . to_s ) )
17+
18+ # Read and combine all CSS files
19+ css = candidates . filter_map do |path |
20+ begin
21+ File . read ( path )
22+ rescue => e
23+ Rails . logger . warn "Could not read compiled CSS from #{ path } : #{ e . message } "
24+ nil
25+ end
26+ end . join ( "\n " )
27+
28+ Rails . logger . warn "No CSS files found for PDF generation" if css . blank?
29+ %>
930 < style type ="text/css ">
1031 <%= css . html_safe %>
1132 </ style >
You can’t perform that action at this time.
0 commit comments