# Acts as attachment

**URL:** <https://www.ruby-forum.com/t/acts-as-attachment/103064>\
**Category:** IT\
**Created:** [May 1, 2007, 11:44am UTC](https://www.ruby-forum.com/t/acts-as-attachment/103064 "2007-05-01T11:44:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e68b1a/32.png) [@stb](https://www.ruby-forum.com/u/stb)\
**Post date:** [May 1, 2007, 11:44am UTC](https://www.ruby-forum.com/t/acts-as-attachment/103064/1 "2007-05-01T11:44:44Z")

</div>

Ciao,

sto provando ad usare questo plugin per gestire l’ upload di immagini  
ma ho qualche problema a farlo andare. nel modello ho specificato il  
sistema di storage e alcune limitazioni sui tipi di file(dovrebbe  
accettare solo immagini).  
Il problema è che quando provo a caricare il file con “create” mi da  
validation failed: conent type is not included in the list; content  
type can’t be blank ecc.

class Photo \< ActiveRecord::Base  
acts\_as\_attachment :storage =\> :file\_system, :content\_type =\> :image  
validates\_as\_attachment  
end

\<% form\_remote\_tag(:url =\> {:controller =\> “picture”, :action =\>  
“create”,:update =\> “” }, :html =\> { :multipart =\> true }) do -%\>

```
 <p><%= file_field :photo,:uploaded_data %></p>
 <p><%= submit_tag :Create %></p>

```

\<% end -%\>

def create  
@photo = Photo.create! params[:photo]

```
     render :update do |page|
       page.alert "creato"
     end
 rescue Exception => e
     render :update do |page|
       page.alert e.to_s
     end

```

end\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
Ml mailing list  
removed\_email\_address@domain.invalid  
[http://lists.ruby-it.org/mailman/listinfo/ml](http://lists.ruby-it.org/mailman/listinfo/ml)
