Hola
Estoy usando attachment_fu y RMagick para subir fotos, cambiar el tamaño
y crear un thumbnail.
El caso que cuando añado una imagen, la primera vez la hace bien y el
resto da error al hacer el save en el controlador. Asà que tengo parar
el servidor y volver a arranzarlo y entonces la sube…
Mi código es este:
new.rhtml
New mugshot
<%= error_messages_for :whatever %>
<% form_for(:mugshot, :url => { :action => “create” },
:html => { :multipart => true }) do |f| -%>
Upload A Mugshot: <%= f.file_field :uploaded_data %>
<%= submit_tag 'Create' %>
<% end -%>Controller
class MugshotsController < ApplicationController
def show
@mugshot = Mugshot.find(:all)
end
def create
@mugshot = Mugshot.new(params[:mugshot])
if @mugshot.save
flash[:notice] = ‘Photo saved successfully!’
render :action => “show”
else
flash[:notice] = ‘There was a problem!’
render :action => “new”
end
end
end
Model
class Mugshot < ActiveRecord::Base
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 2.megabyte,
:resize_to => ‘640x480>’,
:path_prefix => “./public/images”,
:thumbnails => { :thumb => ‘100x100>’ },
:processor => :Rmagick
validates_as_attachment
end
¿Alguien sabe porqué puede ser?
Muchas gracias