'How I take a link from my JSON data and make it into an image via Ruby on Rails?
<%= @schedule["data"][0]["visitorTeam"]["data"]["name"] %>
<%= @schedule["data"][0]["visitorTeam"]["data"]["logo_path"] %>
<%= @schedule["data"][0]["localTeam"]["data"]["name"] %>
<%= @schedule["data"][0]["localTeam"]["data"]["logo_path"] %>
Renders me
Rangers
https://cdn.sportmonks.com/images/soccer/teams/30/62.png
Celtic
https://cdn.sportmonks.com/images/soccer/teams/21/53.png
I'm creating a schedule page, so I'd like to set up the view so that it just goes to the same area of the respective JSON for each image. How do I make it so that it recognizes the link and turns it into an image every time it goes to "logo_path"?
I've tried something like
<%= image_tag <%= @schedule["data"][0]["localTeam"]["data"]["logo_path"] %> %>
but it didn't work for me. Any suggestions?
Solution 1:[1]
<%= image_tag @schedule["data"][0]["localTeam"]["data"]["logo_path"] %>
No need of an extra <%=.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | brcebn |
