# Problemi con acts\_as\_attachment

**URL:** <https://www.ruby-forum.com/t/problemi-con-acts-as-attachment/105717>\
**Category:** IT\
**Created:** [June 1, 2007, 6:04pm UTC](https://www.ruby-forum.com/t/problemi-con-acts-as-attachment/105717 "2007-06-01T18:04:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarini](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@tarini](https://www.ruby-forum.com/u/tarini)\
**Post date:** [June 1, 2007, 6:04pm UTC](https://www.ruby-forum.com/t/problemi-con-acts-as-attachment/105717/1 "2007-06-01T18:04:34Z")

</div>

salve ragazzi, so che qualcuno di voi puo aiutarmi con questo  
celeberrimo  
plugin.

il problema è che non mi genera nessuna thumbnail dell’immagine passata  
come  
parametro… la salva correttamente ma niente thumb  
MODEL  
class Photo \< ActiveRecord::Base  
acts\_as\_attachment :storage =\> :file\_system,  
:thumbnails =\> { :normal =\> ‘300\>’, :thumb =\>  
‘50’ }  
validates\_as\_attachment  
end

CONTROLLER  
class PhotoController \< ApplicationController  
…  
def create  
@photo = Photo.create! params[:photo]  
redirect\_to :action =\> ‘show’, :id =\> @photo  
rescue ActiveRecord::RecordInvalid  
render :action =\> ‘new’  
end  
end

VIEW  
\<% form\_for :photo, :url =\> { :action =\> ‘create’ }, :html =\> {  
:multipart  
=\> true } do |f| -%\>

\<%= f.file\_field :uploaded\_data %\>

\<%= submit\_tag :Create %\>

\<% end -%\>

si comporta come se l’opzione :thumbnail non ci sia… ☹ ☹

–  
everything has got to end sometime we were satellites drifting off into  
space  
vega 4 - burn and fade away

---

<div class="post-metadata">

**Author:** ![tarini](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5f8ce5/32.png) [@tarini](https://www.ruby-forum.com/u/tarini)\
**Post date:** [June 1, 2007, 6:59pm UTC](https://www.ruby-forum.com/t/problemi-con-acts-as-attachment/105717/2 "2007-06-01T18:59:40Z")

</div>

On ven, 2007-06-01 at 18:03 +0200, tarini wrote:

> end  
> end

Guarda l’ho presa dagli archivi del supporto tecnico non so se sia  
pertinente col tuo problema:

Linea 142  
vendor/plugins/acts\_as\_attachment/lib/technoweenie/acts\_as\_attachment/instance\_methods.rb

sostituisci con (parent\_id.nil? || parent\_id == 0)

Se ho ben capito il problema e’ che prima di generare la thumbnail  
verifica che il campo parent\_id sia NULL ma in realta’ di default viene  
inizializzato a 0
