Dachte das wäre ohnehin klar gewesen, wenn es fast der gleiche Code ist
wie vom Railscast


hier das Model:
class Newsteam < ActiveRecord::Base
 
  has_attached_file :photo, :styles => { :small => "150x150>" },
                    :url  =>
"/photos/newsteam/:id/:style/:basename.:extension",
                    :path =>
":rails_root/public/:attachment/:id/:style/:basename.:extension"

  #validates_attachment_presence :photo
  validates_attachment_size :photo, :less_than => 5.megabytes
  validates_attachment_content_type :photo, :content_type =>
['image/jpeg','image/jpg', 'image/png']
end

new View
<% form_for(@newsteam) do |f| %>
  <%= f.error_messages %>

  <p>
    <%= f.label :vorname %><br />
    <%= f.text_field :vorname %>
  </p>
  <p>
    <%= f.label :nachname %><br />
    <%= f.text_field :nachname %>
  </p>
  <p>
    <%= f.label :ort %><br />
    <%= f.text_field :ort %>
  </p>

  <p>
    <%= f.label :Foto %><br />
    <%= render :partial => 'form', :locals => { :f => f } %>
  </p>
    <%= f.submit 'Create' %>
<% end %>

_form Partial
<% form_for @newsteam, :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
  <%= f.file_field :photo %> <%= f.submit "upload" %>
<% end %>

Thats it


Mathias Meyer wrote:
> 2009/5/18 schroedi <[email protected]>:
>   
>> Ich versuche gerade mit Paperclip ein Profil Foto upload hinzubekommen,
>> irgendwie scheint auch erstmal alles zu klappen, aber auf Show Seite
>> werden nur Platzhalter angezeigt
>>
>> Wo liegt hier mein Fehler?
>>
>>     
> Der Fehler liegt erstmal darin, dass du keinen Code dazu gezeigt hast.
> Ist dein Formular denn auch mit dem dem Parameter :multipart => true
> erstellt bzw. mit dem Attribut enctype="multipart/form-data" versehen?
>
> Cheers, Mathias
>   

-- 

Mario Schröder | http://www.ironschroedi.com/de/
Office: +49 361 2152062
Phone: +49 34464 62301 Cell: +49 163 27 09 807
http://www.xing.com/go/invite/6035007.9c143c

_______________________________________________
rubyonrails-ug mailing list
[email protected]
http://mailman.headflash.com/listinfo/rubyonrails-ug

Antwort per Email an