I am using acts_as_attachment to upload multiple files and it works
great. My problem is when I go to display the files and images. If one
or more files are missing I get an error stating “can’t convert nil
into String” what I then tried is the following:
This clears the error but then it also hides the pdf icon for all
other records. How would I go about hiding the pdf icon if there isn’t
a file associated with that record but show it if there is a file?
That’s not really Rails as much as Ruby. In your if statement, you’re
condition is checking if an empty string is blank, which it will always
be. You’d get the exact same result if it said <% if 1 == 1 %>, or even
<% if true %>. The condition you need to be checking is whether or not
the file in question is available on the server.