Stylesheet_link_tag is broken, paths to files not working, can't figure out why for the life of me. Any ideas?
have you put your images in assets/images
directory?
Rails 6.1.1 doesn't load the webpacker created CSS files in production mode
We had the same issue with the match?
method missing for ActionDispatch::FileHandler
We traced it back to: https://github.com/romanbsd/heroku-deflater/issues/54
Removing the heroku-deflater gem fixed it for us
Rails 4: assets not loading in production
In /config/environments/production.rb
I had to add this:
Rails.application.config.assets.precompile += %w( *.js ^[^_]*.css *.css.erb )
The .js was getting precompiled already, but I added it anyway. The .css and .css.erb apparently don't happen automatically. The ^[^_]
excludes partials from being compiled -- it's a regexp.
It's a little frustrating that the docs clearly state that asset pipeline IS enabled by default but doesn't clarify the fact that only applies to javascripts.
Sprockets::Rails::Helper::AssetNotPrecompiled in ResqueWeb
resque comes with a built-in server. You do not need resque-web
and it seems it is not maintained (last commit was on 2018).
Let's try this:
gem 'resque', require: 'resque/server'
# routes.rb
mount Resque::Server.new, :at => "admin/resque"
Make sure you allow just admins to access to that page in production. For that you could read about Route Constraints to do something like:
constraints IsResqueAllowed do
mount Resque::Server.new, :at => "admin/resque"
end
class IsResqueAllowed
def self.matches?(request)
# use the request to do something
end
end
More information about securing the route here.
Rails 7 engine how to make uncompiled stylesheets available to host app?
Thanks for clarifying. If I understood correctly here my take on it.
partials are not not available in a host app as the engine has already compiled them
Partials are still there, precompilation just outputs *.{css/js}
files into public/assets/
that are declared in app/assets/config/manifest.js
.
To get to engines files, instead of Rails.root
use:
CcsCms::PublicTheme::Engine.root
In Css
class, for example:
def get_stylesheet_path
CcsCms::PublicTheme::Engine.root.join("app/assets/stylesheets/ccs_cms/public_theme")
end
To support changing theme engines. Theme root can be set in an engine initializer to something like Rails.configuration.theme_root
and used in the main app.
Because your theme is also configurable, I think it's better to read theme's original sass files but not modify them, copy them into a tmp folder and update with values from theme table, then output a theme.css
in the main app with sass.
https://sass-lang.com/documentation/cli/dart-sass
# Compiles all Sass
$ sass tmp/theme/application.scss:app/stylesheets/theme.css
Then let Rails take over the precompilation process.
Another option is to have one sass configuration file and only update this file. That way there is no dependency on the file structure of any particular theme.
import 'configuration' // sass variables with values from theme table
import 'banner' // uses sass variables only
...
Also just use css variables, if that's an option, and avoid all of the above complexity; no precompilation, no redeploys when theme table changes.
Update for css variables.
Just so we're on the same page. I meant these css variables:
https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties. If Internet Explorer is not a priority for you, this is the best solution.
The setup is something like this:
<!-- app/views/layouts/application.erb -->
<!-- NOTE: with turbo this loads only once; full page refresh is needed when @theme changes -->
<head>
<style>
:root { --text-color: <%= @theme.text_color %>; }
</style>
<%= stylesheet_link_tag 'application' %>
</head>
/* app/assets/stylesheets/application.css */
p { color: var(--text-color); }
Possible fix to avoid amending css files. Use erb
interpolation inside the sass files. No need to amend every time a theme configuration is changed. In development compiles on the fly. In production it has to be precompiled again when theme configuration is changed; no amending.
// _banner.scss.erb
p { color: <%= Theme.text_color %>; }
You could even use amend_css_for
function to insert literal erb code and save some time. For example
new_line = ma + ": <%= Theme.#{model_name}.#{field_name} %>;"
Finally, if you don't want to touch engine files and because these files are not part of the main/host app (as in literally two separate folders in the filesystem). You have to make a copy when amending; read from CcsCms::PublicTheme::Engine.root
write to Rails.root
.
def get_stylesheet_path
CcsCms::PublicTheme::Engine.root.join("app/assets/stylesheets/ccs_cms/public_theme")
end
# but save to main app
def create_css_files_for(file_name, css_array)
File.open("#{Rails.root.join("app/assets/stylesheets/ccs_cms/public_theme")}/#{file_name}", "w") do |file|
file.puts css_array
end
end
Heroku Not Showing SCSS Background Images
Look at your paths.. It must be something with your configuration. You've got your absolute path in code somewhere, either that or it's on track to something related. Search your code-base and make sure you don't have your own machine's absolute path hard-coded anywhere. Make sure it is all relative. /Users/elizabethbayardelle/Dropbox/Code/BIA/
should not be anywhere in your source, but somewhere it is being used in your herokuapp instance. On your localhost screenshot you've even got a path to heroku.com
... how? A second take over how you've configured things will fix this I'm sure.
Related Topics
How to Use a Material Theme Colors in My CSS in Angular2
Card Back Hidden on First Transition in Chrome
Overriding Overflow-X CSS Property on iOS
How to Change My Gwt Listbox Style
Google Font Not Showing in Firefox
Style The Tawk.To Chat Widget with My Custom CSS
†Appearing Instead of Quotation Marks
Possible to Set Hex Color Opacity Independently
How to Select Nth Child of Specific Tag with CSS
Issue with Embedded Svg Images in Dark Mode
CSS- Webkit-Text-Stroke But Stroke Covers Font-Color
Is There Any Possibilty Using CSS-Variables in Sass