mardi 3 février 2015

Proper way to load paperclip images in ember?

I have a Rails 4 api that feeds my Ember.js application in a different folder (and port) on my computer. I use paperclip to handle image uploads on the rails side through active admin which works great but I am now trying to get the images to display correctly in Ember. I have a method for doing this where I add "http://localhost:3000" to the front of the image string coming over and this works but it feels dirty. What is the proper way to do this? Thanks for the help!


To start, I have a serializer which makes the various paperclip attributes available to the ember:


Rails Serializer:



class CourseSerializer < ActiveModel::Serializer
attributes :id,:name,:courseImage
end


Ember Model:



import DS from 'ember-data';

export default DS.Model.extend({
name: DS.attr('string'),
courseImage: DS.attr('string')

fullURL: function() {
return "http://localhost:3000"+ this.get('courseImage');
}.property('courseImage')
});


This way also gives me an error even though the image displays in the browser:



[Report Only] Refused to load the image 'http://localhost:3000/system/courses/courseimages/000/000/001/original/courseimage.png?1422943297' because it violates the following Content Security Policy directive: "img-src 'self'".




Aucun commentaire:

Enregistrer un commentaire