Closed rnevius closed 1 year ago
Could you provide what you have in config/initializers/rails_admin.rb
?
Sure thing! Here are the contents of config/initializers/rails_admin.rb
:
RailsAdmin.config do |config|
config.asset_source = :webpacker
config.parent_controller = "::AdminController"
## == Devise ==
config.authenticate_with { warden.authenticate! scope: :user }
config.current_user_method(&:current_user)
config.authorize_with do |controller|
if current_role != "admin"
redirect_to "/", alert: "Unauthorized"
end
end
config.actions do
dashboard # mandatory
index # mandatory
new
export
bulk_delete
show
edit
delete
show_in_app
import
config.default_hidden_fields[:edit] = [:id, :updated_at]
config.default_hidden_fields[:show] = [:id]
end
end
There's at least one other instance of this happening, but there isn't much context provided: https://stackoverflow.com/questions/75022373/sidekiq-and-rspec-doesnt-work-after-rails-admin-upgrade-to-3-1-1
My guess is for some reason the asset rails_admin/application.js
is picked up by your app, which is for Sprockets-based setup and not to be used with asset_source = :webpacker
.
Could you check following points?
grep -r rails_admin app/assets/config app/assets/javascripts
in your Rails application's root?Rails.application.config.assets.precompile
from Rails console?What do you get if you do grep -r rails_admin app/assets/config app/assets/javascripts in your Rails application's root?
The app/assets/javascripts
directory doesn't exist. I'm using webpacker and all javascript assets are packs in app/javascript/packs
. There's nothing related to rails admin in the manifest.js file in app/assets/config
.
What's the output of Rails.application.config.assets.precompile from Rails console?
irb(main):023:0> Rails.application.config.assets.precompile
=>
[#<Proc:0x0000ffff8183b838 /usr/local/bundle/gems/sprockets-rails-3.4.2/lib/sprockets/railtie.rb:88 (lambda)>,
/(?:\/|\\|\A)application\.(css|js)$/,
"turbo.js",
"turbo.min.js",
"turbo.min.js.map",
"rails_admin/application.js",
"rails_admin/application.css"]
Thanks, config.assets.precompile
shouldn't contain rails_admin/application.js
and rails_admin/application.css
and that's the cause.
The question is where they came from. Could you try grep -r rails_admin/application .
in the Rails app root?
❯ grep -r rails_admin/application .
Binary file ./tmp/cache/bootsnap/load-path-cache matches
Binary file ./tmp/cache/bootsnap/compile-cache-iseq/a4/5560d61065a40d matches
Binary file ./tmp/cache/bootsnap/compile-cache-iseq/c4/6dd5ecb4a5a2a9 matches
Does rails tmp:clear
make difference?
It doesn't 😞
This was an issue with Sprockets itself. Upgrading from 3.7 -> 4.2 fixes the problem. Apologies for sending you on a futile search.
Great that you could find the cause! This will also help others who have this issue 👍
I had this same issue as well. Upgrading Sprockets from 3.7 -> 4.2 also fixed it for me.
Describe the bug
After upgrading from 3.0.0 to 3.1.0, Webpacker is able to compile the front-end, but rails
image_tag
calls throw the following error:Reproduction steps
Seems like just upgrading to 3.1 from 3.0 is enough to cause the issue. Re-running the installer doesn't fix anything.
Additional context
rails
version: 6.1 (using webpacker)rails_admin
version: 3.1rails_admin
npm package version: 3.1