vendredi 4 septembre 2015

Domain name missing in image paperclip in to_json rails 4

I have the model that uses paperclip like this

has_attached_file :image, styles:  { :medium => "50x50>" }
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/

def image_url
    image.url(:medium)
end

I need it Json, So in my controller,

respond_to do |format|
  format.json { render json: @celebrity.to_json(:methods => [:image_url])}      
end

And the result is

"image_url":"/system/celebrities/images/000/000/003/medium/Designed___developed_by_wd_ApS.png?1430926991"

but, I need to include the domain name, localhost:3000 , So what I have to do here

Aucun commentaire:

Enregistrer un commentaire