Estoy usando CarrierWave en mi aplicación de muestra Rails 3. Quiero validar la carga ubicación remota por lo que no entiendo la excepción error estándar cuando un usuario envía una URL no válida, ya sea en blanco o no una imagen:¿Cómo lo hago: validación de ubicación remota con CarrierWave?
CarrierWave::DownloadError in ImageController#create
trying to download a file which is not served over HTTP
Ésta es mi modelo:
class Painting < ActiveRecord::Base
attr_accessible :gallery_id, :name, :image, :remote_image_url
belongs_to :gallery
mount_uploader :image, ImageUploader
validates :name, :presence => true,
:length => { :minimum => 5, :maximum => 100 }
validates :image, :presence => true
end
ésta es mi controlador:
class PaintingsController < ApplicationController
def new
@painting = Painting.new(:gallery_id => params[:gallery_id])
end
def create
@painting = Painting.new(params[:painting])
if @painting.save
flash[:notice] = "Successfully created painting."
redirect_to @painting.gallery
else
render :action => 'new'
end
end
def edit
@painting = Painting.find(params[:id])
end
def update
@painting = Painting.find(params[:id])
if @painting.update_attributes(params[:painting])
flash[:notice] = "Successfully updated painting."
redirect_to @painting.gallery
else
render :action => 'edit'
end
end
def destroy
@painting = Painting.find(params[:id])
@painting.destroy
flash[:notice] = "Successfully destroyed painting."
redirect_to @painting.gallery
end
end
no estoy muy seguro de cómo hacer frente a este problema de manera alguna idea sería grande.
No estoy seguro de si la mejor manera de hacerlo es crear: valida: remote_image_url en el Modelo y tiene una expresión regular para validar si se trata de una URL y una imagen. –