-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
undefined method `assets' for #<Rails::Application::Configuration #50
Comments
Hey @AlicjaCyganiewicz I'm hitting the same error. May I ask where you did add this conditional? Did you use a fork of the gem? |
@nicalpi I had the same issue and had to fork the gem with that conditional. And then added the following initializer to fix the styling of the UI. # config/initializers/audits1984.rb
unless Rails.application.config.respond_to?(:assets)
gem_asset_root = Audits1984::Engine.root.join("app/assets")
tmp_asset_root = Rails.root.join("tmp/audits1984/assets")
# Create audits1984 css and js files
asset_files = [
"javascripts/audits1984/application.js",
"stylesheets/audits1984/bulma.min.css",
"stylesheets/audits1984/application.css",
]
asset_files.each do |file|
unless (local_file = tmp_asset_root.join(file)).exist?
local_file.dirname.mkpath
local_file.write gem_asset_root.join(File.dirname(file)).children.map(&:read).join("\n\n")
end
end
# Serve custom assets instead of audits1984's (that will 404 without the asset pipeline)
Rails.application.config.middleware.use Rack::Static,
urls: %w[/javascripts/audits1984 /stylesheets/audits1984 /images/audits1984],
root: tmp_asset_root
end |
Nice, thanks a lot @coalest. I ended up doing something similar in the end, so it's good to know I'm not the only one with the same issue. |
We've had to do the same, definitely feels like something that should be fixed without forking |
add a fix for "undefined method `assets'" based on comments in #50
Revert "add a fix for "undefined method `assets'" based on comments in #50"
Sorry, I'm reopening this one as the patch I had merged wasn't really feasible as a generic solution for the gem. If you're not using propshaft/sprockets, what are you using? I'd be willing to add support for import maps such as we do in Mission Control jobs (see this and this). Is someone willing to work on that? |
@jorgemanrubia Our asset pipeline is outsourced to a CDN, packaged along with our Vue frontend. For serving other assets, like the Sidekiq Web UI, we serve it directly through Rack, similar to how the PR above does it. I'm also open to having an API-only mode, where there is no UI. |
On our end, we're using Isn't it risky to end up having tons of additional implementations in the |
@rosa just addressed this same problem for Mission control jobs. I'd like to use the same approach here. I'll try to get to this but I have other things in my queue, so I'd appreciate a PR if someone feels like working on this. |
I'll have a look, @jorgemanrubia! 🙏 Also, @jipiboily, I realised I forgot about |
@jipiboily, I spent some time looking into |
@AlicjaCyganiewicz @nicalpi @coalest @humzahkiani-JW @jipiboily, if you want to give a try at #61 please do! I hope it fixes your issues. Basically, just add |
@rosa it appears to work with |
Ohh, unfortunately that means it's not quite working as it should, as the CSS are one of the things that should be working fine thanks to importmaps and propshaft. Could you check the request to fetch the CSS in your network tab and find the corresponding request in your local server to see why it's not finding it? |
It appears that the CSS requests are being mistakenly routed to our react frontend, which returns the default react HTML page. Does this match what a typical path should be for the CSS request? |
Thank you both for your help here! |
As we're not using
# require "sprockets/railtie"
- I've encountered a problem with audits1984 engine:undefined method 'assets' for #<Rails::Application::Configuration
I fixed it locally by conditional statement
Would that be a problem to merge it into code base 🥺 ?
Cheers!
The text was updated successfully, but these errors were encountered: