Seeking assistance as I am struggling to get my CSS files loaded correctly in production for my 3.2 RoR app. Despite trying various methods, the files either do not appear or result in a 404 error.
My application utilizes a combination of a purchased theme and Bootstrap. While everything looks fine during development, once deployed to production, things start to go awry.
In addition, I have two layouts: application.html.erb and homepage.html.erb. The application.html.erb makes reference to an additional CSS file as outlined below.
Within my app/assets/stylesheets directory, the structure is as follows:
stylesheets
+compiled
--theme.css #includes bootstrap/bootstrap.min.css
--custom_theme.css #additional CSS used in application.html.erb
+vendor
--animate.css
--brankic.css
+bootstrap
--bootstrap.min.css
application.css
inbox.css
The application.html.erb layout explicitly calls the following CSS:
<%= stylesheet_link_tag 'compiled/theme.css', 'vendor/brankic.css', 'vendor/animate.css', 'compiled/custom_theme.css', 'inbox.css' %>
While the homepage.html.erb layout specifically includes the following CSS:
<%= stylesheet_link_tag 'compiled/theme.css', 'vendor/brankic.css', 'vendor/animate.css', 'inbox.css' %>
I have tried using application.css with *= require_tree ., but this loads unnecessary files. Similarly, creating a homepage.css without custom_theme still requires *= require_tree . for references in theme.css.
Moreover, I attempted pre-compiling the CSS in my config/env/prod file, but the referenced CSS files are not being pulled in.
EDIT
Based on Mike's advice, I have added the following to my config/env/prod file:
config.assets.precompile += ['bootstrap/bootstrap.min.css','compiled/theme.css', 'vendor/brankic.css', 'vendor/animate.css', 'se2b_custom.css', 'inbox.css']
Despite this addition, I continue to directly call each CSS as mentioned above, resulting in a 404 error for each file in production.
When inspecting the source code of a page using the homepage layout, the following links are displayed:
<link href="/assets/bootstrap/bootstrap.min.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/compiled/theme.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/vendor/brankic.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/vendor/animate.css?body=1" media="screen" rel="stylesheet" type="text/css" />
<link href="/assets/inbox.css?body=1" media="screen" rel="stylesheet" type="text/css" />
However, clicking on each link leads to a 404 error.