dyserone dyserone - 5 months ago 220
Ruby Question

Rails, "nil is not a valid asset source" for a particular image_tag (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
in my newsPartial and activityPartial work just fine, but my infoPartial
gives me:

nil is not a valid asset source

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

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

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


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