dyserone dyserone - 4 months ago 243
Ruby Question

Rails, just upgraded my projects to rails 5, a particular image_tag not working (Carrierwave)

I have just upgraded to Rails 5 and I have a weird issue while using CarrierWave.

I have the exact same line of code in 3 partials:

<td><%= image_tag article.image_url(:thumb) %> </td>


The weird thing here is that the
image_tag
in my newsPartial and activityPartial work just fine, but my infoPartial
image_tag
gives me:

nil is not a valid asset source


All of them are
Articles
, and before upgrading to Rails 5, I didn't have any similar issue.

My
Article
model just for reference:

class Article < ActiveRecord::Base
has_many :article_localizations, dependent: :destroy

enum article_type: [:news, :info, :accommodation, :history, :activity]

mount_uploader :image, ImageUploader
end


What could be at fault here? Can it be something else and not a Rails upgrade issue?

Answer

The problem was that I was trying to show an image that did not exist. adding unless area.image.blank? solved it.

Comments