I am trying to check if a file exists so that I can either display the image or a placeholder but the placeholder is always shown. If the conditional statement is removed then the logo is displayed fine.
<% if File.exists?(Rails.root + '/public/images/portal/logos/' + @organisation_id + '.png') %>
<img src="/images/portal/logos/<%= @organisation_id %>.png" alt="<%= @person.organisation.name %>">
<% else %>
<img src="http://placehold.it/300x83&text=Please+upload+your+company+logo">
<% end %>
I've read a few questions but most seem to relate to Rails 3 but seeing as I don't get any errors I thought this would work.
Rails.root
is working in rails 2? it may be RAILS_ROOT