How to get only image src attribute from rails image_tag?

Viewed 148

I have a scenario in which I only need the src attribute generated by image_tag.

ActionController::Base.helpers.image_tag("diane.png")

gives back

<img src=\"/assets/diane-d88012c06a724682b02dfbd9224dbaac15872a3.png\" alt=\"Diane\" />

I only need the string in the src attribute.

1 Answers

You can use image_path:

 ActionController::Base.helpers.image_path("diane.png") 
Related