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 Was habe ich getan. Erstmal habe ich script/generate paperclip newsteam photo (wie in Railscast 134 beschrieben) http://railscasts.com/episodes/134-paperclip Aber beim ersten Speichern des Fotos bekomme ich das hier in den Logs anzeigt. Logischerweise bekomme ich dann in meiner Übersicht auch keine Fotos anzeigt.... denn der file_name ist NULL - Newsteam Create (1.2ms) INSERT INTO `newsteams` (`updated_at`, `photo_file_name`, `photo_file_size`, `Beschreibung`, `photo_updated_at`, `ort`, `agb`, `photo_content_type`, `nachname`, `vorname`, `Foto`, `created_at`) VALUES('2009-05-18 12:29:57', NULL, NULL, NULL, NULL, 'freyburg', NULL, NULL, 'Schröder', 'Mario', NULL, '2009-05-18 12:29:57') [paperclip] Saving attachments. [paperclip] Saving files for photo [paperclip] Deleting files for photo [paperclip] Writing files for photo Rendering template within layouts/anmeldung Rendering newsteams/show Wo liegt hier mein Fehler? Mario -- 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
on 2009-05-18 14:36
on 2009-05-18 15:07
2009/5/18 schroedi <schroedi2001@gmail.com>: > 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
on 2009-05-18 15:15
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:
> 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
on 2009-05-18 17:26
schroedi schrieb: > :path => > <%= f.error_messages %> > <%= f.label :ort %><br /> > _form Partial > <% form_for @newsteam, :html => { :multipart => true } do |f| %> > <%= f.error_messages %> > <%= f.file_field :photo %> <%= f.submit "upload" %> > <% end %> das hat Ryan aber so nicht gemacht und dürfte der Grund sein. Das file_field gehört direkt ins erste Formular - und dieses mit multipart-Funktionalität ausgestattet. Ob verschachtelte Formulare überhaupt HTML-konform sind? Torsten
on 2009-05-18 17:32
Torsten Flammiger schrieb: >> "/photos/newsteam/:id/:style/:basename.:extension", >> :path => >> ":rails_root/public/:attachment/:id/:style/:basename.:extension" das scheint auch nicht zu passen: :rails_root/public/:attachment/:id/:style/:basename.:extension es müßte doch so lauten: :rails_root/public/photos/newsteam/:id/:style/:basename.:extension to
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.