Icons from CSS not getting complete URL

8 views
Skip to first unread message

Dennis Bulgatz

unread,
Apr 14, 2021, 9:04:23 PM4/14/21
to ActiveScaffold : Ruby on Rails Gem
Hi Sergio,

Can you let me know if this is a bug, or something I can fix with a configuration.  The AS icons are not getting correctly referenced in my production application, which has a URL Prefix.

For example 

For Google Dev Tools, the missing resource is located here:

/* line 30, vendor/bundle/ruby/2.7.0/gems/active_scaffold-3.6.0.rc2/app/assets/stylesheets/active_scaffold_images.scss

raw CSS in the above file, using the image_url helper.
.active-scaffold a.inline-adapter-close {
background-image: image-url('active_scaffold/close.png');
}

For "everything else", I handle the URL prefix as follows:

$ SUB_URI="/sls1-cache"

$ bundle exec rails assets:precompile RAILS_RELATIVE_URL_ROOT="$SUB_URI" --trace RAILS_ENV=production


Any ideas why this is not working for the AS stuff?

Thanks for any help you might offer.

Dennis

Dennis Bulgatz

unread,
Apr 14, 2021, 10:29:54 PM4/14/21
to ActiveScaffold : Ruby on Rails Gem
Maybe a long shot, but in vendor/bundle/ruby/2.7.0/gems/active_scaffold-3.6.0.rc2/app/assets/stylesheets/active_scaffold_images.scss should we replace image-url with image_url to correspond to the rails helper name?

Sergio Cambra

unread,
Apr 15, 2021, 10:45:19 AM4/15/21
to ActiveScaffold : Ruby on Rails Gem, Dennis Bulgatz

I don't think so, I think right method in SCSS is image-url


I have never used path prefix with rails. I have search how it should work and the right way is using RAILS_RELATIVE_URL_ROOT. However I don't know if it makes a difference using RAILS_RELATIVE_URL_ROOT at beginning or at end, I guess it should be the same, I have tested and both worked:


$ bundle exec rails assets:precompile RAILS_RELATIVE_URL_ROOT=/test         
yarn install v1.22.10 
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.05s.
I, [2021-04-15T16:13:13.432813 #37031]  INFO -- : Writing /home/sergio/web/test52/public/assets/application-7e07b7fb4f6b6d58fc6d51c49c8467fa96313569b03c15ad88af3a03a0685cc0.css
I, [2021-04-15T16:13:13.433025 #37031]  INFO -- : Writing /home/sergio/web/test52/public/assets/application-7e07b7fb4f6b6d58fc6d51c49c8467fa96313569b03c15ad88af3a03a0685cc0.css.gz
$ grep url.*close public/assets/application-*.css
 background-image: url(/test/assets/active_scaffold/close-37f05b17a34211c668917ca9b4c6990995e3339f84b99942432fc4139038c06e.png);
 background-image: url(/test/assets/active_scaffold/close_touch-f9ba6b60291341555ef15114f23d5dd8ccb40a6ccecbdffa6b5318976c42ff31.png);
What rails version are you using? I have tested with both rails 5.2 and 6.0, it worked in both


Regards


El jueves, 15 de abril de 2021 4:29:54 (CEST) Dennis Bulgatz escribió:

> Maybe a long shot, but in

> vendor/bundle/ruby/2.7.0/gems/active_scaffold-3.6.0.rc2/app/assets/styleshee

> ts/active_scaffold_images.scss should we replace* image-url with image_url

> *to correspond to the rails helper name?

Dennis Bulgatz

unread,
Apr 15, 2021, 11:20:06 AM4/15/21
to ActiveScaffold : Ruby on Rails Gem
Hi Sergio. The precompile works fine, and all the assests are created correctly under the public folder.  

I think the issue is the code generating the view seems to not use the right helper, because the URL that is sent to the browser to retrieve the images is wrong (does not include the URL prefix).  Or the helper is grabbing an argument from somewhere?  Have not looked at the AS code that does the view generation to know.

This is an old app, that probably started with Rails 2 or 3, and has been migrated forward over the years to 6.0.3.6.

active_scaffold (3.6.0.rc2)
activerecord (6.0.3.6)

I suspect there is some left over config option somewhere messing things up, assuming you verified not only that the precompile generates the assets, but that the views correctly reference them?

I don't think this should matter, but Using Apache Fusion Passenger to serve the site in production.

With PUMA, running locally, all works fine.

Which Rails 6 version did you test with? Which AS version?

Thanks!

Sergio Cambra

unread,
Apr 16, 2021, 10:53:32 AM4/16/21
to ActiveScaffold : Ruby on Rails Gem, Dennis Bulgatz
Hi

I think you must setup config.relative_url_root or something similar, or maybe
defining RAILS_RELATIVE_URL_ROOT in apache with SetEnv. ActiveScaffold uses
image_path, as any other rails app, so it should work if app is right.

I have tested with 6.0.3.3 and 5.2.5, both with active scaffold master. I only
tested precompiling as I understood you had issues with paths in css.

By the way, you may want to update activescaffold to 3.6.0, which has some
fixes.

Regards
> > *yarn install v1.22.10*
> > [1/4] Resolving packages...
> > success Already up-to-date.
> > Done in 0.05s.
> > I, [2021-04-15T16:13:13.432813 #37031] INFO -- : Writing
> > /home/sergio/web/test52/public/assets/application-7e07b7fb4f6b6d58fc6d51c4
> > 9c8467fa96313569b03c15ad88af3a03a0685cc0.css
> >
> > I, [2021-04-15T16:13:13.433025 #37031] INFO -- : Writing
> > /home/sergio/web/test52/public/assets/application-7e07b7fb4f6b6d58fc6d51c4
> > 9c8467fa96313569b03c15ad88af3a03a0685cc0.css.gz
> >
> > $ grep url.*close public/assets/application-*.css
> >
> > background-image:
> > url(/test/assets/active_scaffold/close-37f05b17a34211c668917ca9b4c6990995e
> > 3339f84b99942432fc4139038c06e.png);>
> > background-image:
> > url(/test/assets/active_scaffold/close_touch-f9ba6b60291341555ef15114f23d5
> > dd8ccb40a6ccecbdffa6b5318976c42ff31.png); What rails version are you

Dennis Bulgatz

unread,
Apr 16, 2021, 1:39:39 PM4/16/21
to Sergio Cambra, ActiveScaffold : Ruby on Rails Gem
Thanks! We updated the app to use Webpack and some part of the update fixed the missing icon issue.

I had not noticed the 3.6.0 release. Well done!

Dennis

> On Apr 16, 2021, at 9:53 AM, Sergio Cambra <ser...@enpijama.es> wrote:
>
> Hi
Reply all
Reply to author
Forward
0 new messages