Some (or all) of @articles
is an array, so the []
method applied in article
expects a number, however you are passing a text string:
<%= article["image_url"] %>
To fix it, you must verify the structure that is returning the API (i.e. print the @articles
content) so that you can give the appropriate treatment to each element.
Generally, with HTTParty.get
(considering the current response of your API), you would do something like this:
@articles = HTTParty.get(...).body[:articles]
<% @articles.each do |article| %>
<%= article["image_url"] %>
<% end %>