First at all sorry if my english is not the best
I have a problem with this plugin. It has been installed because we need
to upload images in our web. We need 3 kinds of images with different
sizes.
this is our code:
Image model:
class Image < ActiveRecord::Base
.
.
.
has_attachment :content_type => [‘image/jpeg’, ‘image/pjpeg’,
‘image/gif’, ‘image/jpg’, ‘image/png’],
:storage => :file_system,
:path_prefix => ‘public/images’,
:size => 1.kilobyte…300.kilobytes,
:resize_to => ‘700>’,
:thumbnails => { :titular1 => ‘220>’,
:titular2 => ‘150>’, :foro => ‘440>’ },
:processor => :MiniMagick
validates_as_attachment
the name of the controller is titulares. The code is like that :
class TitularesController < ApplicationController
.
.
.
def edit
@titulo = “Editar titular”
@titular = Contenido.find(params[:id])
end
.
.
.
def create
@titular=Contenido.new(params[:contenido])
@titular.subtipo_id=Subtipo::TITULARES
# Actualizo el usuario, incrementando sus puntos y su nº de posts de
blog
autor = Usuario.find(@titular.usuario_id)
estadisticas_up(autor.id, Subtipo::TITULARES)
autor.update_attribute(“puntos”, autor.puntos + @titular.puntos_msg)
autor.update_attribute(“puntos_anual”, autor.puntos_anual +
@titular.puntos_msg)
/this is the part of code for the images/
respond_to do |format|
if @titular.save
#guardo las imagenes
unless (image = params[:image]).nil?
img = Image.new(image.merge({:usuario_id =>
session[:usuario_id], :contenido_id => @titular.id, :orden =>1}))
img.save
end
format.html { redirect_to(portada_titulares_path) }
format.xml { render :xml => @titular, :status => :created,
:location => @titular }
else
format.html { render :action => “new” }
format.xml { render :xml => @titular.errors, :status =>
:unprocessable_entity }
end
end
end
.
.
.
OK, when I edit a titular there’s no problem. I can add or edit a photo
perfectly and in my BBDD there are the 3 images with the respective
size. the problem exits whe i want to create a titular, I can add an
image but my BBDD only stores the original image with the original size.
There is not the copies with another sizes.
I don´t know because the anothers sizes there aren´t written in the
BBDD…any help please???