I have a standard image uploader using Carrierwave. I am also using Postgres. So this is what my migration looks like for adding images as JSON:
class AddImagesToListings < ActiveRecord::Migration[5.1]
def change
add_column :listings, :images, :json
remove_column :listings, :image
end
end
I want to make images[0] always have some image, but it seems like the Carrierwave documentation only covers this for single file uploads. Right now, here is my default_url method:
def default_url(*args)
ActionController::Base.helpers.asset_path("default/" + ["default.jpg"].compact.join('_'))
end
This was working when I only had :image, but now it isn't. Is there any way to set a default for images[0] so that I get a valid images[0].url for every listing I have (despite whether or not a user adds an image to the listing)?