Ruby on Rails Sunday, December 22, 2019



On Sunday, December 22, 2019 at 1:50:09 PM UTC-5, Siyanda Maphumulo wrote:
in the file app/assets/config/manifest.js

//= link_tree ../images
//= link application.css

I have images in app/assets/images/

background-image: url(image_path("bg/main.jpg"));


So this is similar to the way you would access images in previous versions of Rails, the linking of those assets is being handled by sprockets and not webpacker.
 

On Sunday, 22 December 2019 20:27:45 UTC+2, fugee ohu wrote:


On Sunday, December 22, 2019 at 11:12:28 AM UTC-5, Siyanda Maphumulo wrote:
.search_button
{
  background:url(image_path("search.png"));
}

more information : https://guides.rubyonrails.org/asset_pipeline.html

On Sunday, 22 December 2019 17:15:59 UTC+2, fugee ohu wrote:
How do I refer to images in stylesheets with rails 6/webpacker I always get can't resolve image.png from code like this:
.search_button

.search_button
{
  background:url(search.png);
}

Not
First, where should I put images Then, how to access them from app/javascripts/stylesheets/application.scss

Sorry I mis-spelled the file name It's emitting now but not rendering I think my html is wrong

 <%= submit_tag "Search", class: submit_button %>

.search_button
{
background-image: url('../images/search-button.png');
}

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ba62b7e5-6ba5-4f43-b0df-f981349cea6f%40googlegroups.com.

No comments:

Post a Comment