Reputation: 829
i want to add an image inside an image tag in rails how to do it? if i try doing the following code it says the blank.gif is not present . how to make it take the asset image part ... my blank.gif is present in asset/images
%img.sp-image{"data-src" => "#{gallery_image.image.url}", :src => "path/to/blank.gif"}/
i want to pass blank.gif in src by using something like asset_url so that it directly locates that file rather than giving the entire file path
Upvotes: 1
Views: 675
Reputation: 318
Your source location to your file is incorrect, If your image resides in assets/images i.e the default location of images then you need not to write assets/images/image_name instead you can directly do assets/image_name.
%img.sp-image{"data-src" => "#{gallery_image.image.url}", :src => "/assets/blank.gif"}/
Upvotes: 1
Reputation: 6865
you can use asset_path
in your HAML
%img.sp-image{:alt => "image description", :src => asset_path("blank.gif")}
Upvotes: 2