user1167219
user1167219

Reputation:

Rails Image loads when visiting URL directly but does not when redirected to

When visiting the page directly of which its view looks as following:

<img src='assets/logo.jpg',height="400", width="1600"></img>

<%= render 'form' %>

<div style="text-align:center;">

<%= link_to 'Register', new_user_path %>

</div>

The pointed asset loads, but when this view is redirected to the asset does not load.

What is rails doing that I dont know about?

Upvotes: 0

Views: 58

Answers (1)

hyperrjas
hyperrjas

Reputation: 10744

you must use image_tag helper:

http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html#method-i-image_tag

your example instead:

<img src='assets/logo.jpg',height="400", width="1600"></img>

you must use:

<%= image_tag("logo.jpg"), :size => "1600x400" %>

Regards!

Upvotes: 3

Related Questions