I have problem whit the next code:
$scope.load_icons = function(file){
filename = file[0].name;
filenamearray = filename.split('.');
extencion = filenamearray[filenamearray.length-1];
console.log(user_profiling);
if(extencion==='png'||extencion==='gif'||extencion==='jpg'||extencion==='PNG'||extencion==='GIF'||extencion==='JPG'){
$upload.upload({
url: '/user_icons.json',
data: {},
file: file
}).progress(function(evt){
console.log(evt);
}).success(function(data, status, headers, config) {
console.log(data);
}).error(function(data, status, headers, config){
console.log(data);
});
}
}
user_icon.rb
class UserIcon < ActiveRecord::Base
has_attached_file :image, :styles => { :d512 => "512x512>", :d256 => "256x256", :d256 => "256x256", :d128 => "128x128", :d64 => "64x64", :d32 => "32x32" }, :default_url => "/marker/:style/missing.png"
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/
end
user_icons_controller.rb
class UserIconsController < ApplicationController
skip_before_filter :verify_authenticity_token
def create
@icon = UserIcon.new(params)
respond_to do |format|
if @icon.save
format.html { redirect_to @icon, notice: 'Category was successfully created.' }
format.json { render action: 'show', status: :created, location: @icon }
else
format.html { render action: 'new' }
format.json { render json: @icon.errors, status: :unprocessable_entity }
end
end
end
private
def icons_params
params.require(:image).permit(:tempfile)
end
end
I require loading and resize images to be icons (markers) but I get the following error:
And I keep in the URL database of the generated images.
Thank you very much for the help