ruby on rails - TypeError (Can't convert nil into String) With Attachment_Fu -


I am handling file attachments in my Rail app with attachment_foo, which is the public_filename method Returns the URL of a file that I am using on a model called Cover, so if I want to call the URL of an uploaded cover image, then I will do this:

  & lt;% = image_tag (@cover .public_filename)%>  

This works fine when the user has a proper attachment, but in my application it does not need to upload an attachment for a user. Therefore, a TypeError will be thrown by calling @ cover.public_filename : For obvious reasons, the zero in the string can not be changed that the file is zero.

However, I have trouble connecting the logic of this problem effectively because the object is zero, and with all the things like doing all the efforts @press.public_filename.nil? or if@cover .public_filename == Zero is meaningless and causes the same type of error.

What am I missing?

I have not worked with attachment_fu, but as I have seen public_filename is such a method that Depends on the field when you do not have attachments attached. I have read that attachment_fu should always be an attachment - and this is probably one of the reasons why you did not do this job. The authors also recommend using the plugin. Look at it!


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -