1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
view :

<% form_for @project_album, :html => { :multipart => true } do |f| %>
  <%= f.error_messages %>
  <p>
    <%= f.label :photo %><br />
    <%= f.file_field :photo %>
  </p>
  <p>
    <%= f.label :project_id %><br />
    <%= f.text_field :project_id %>
  </p>
  <p>
    <%= f.label :description %><br />
    <%= f.text_area :description %>
  </p>
  <p><%= f.submit "Submit" %></p>
<% end %>


model :

  has_attached_file :photo, :styles => { :original => "125x125>" }, 
                  :url  => "/images/project/:id/:style/:basename.:extension",
                  :path => ":rails_root/public/images/project/:id/:style/:basename.:extension" 
  validates_attachment_presence :photo

Log :

Processing ProjectAlbumsController#create (for 127.0.0.1 at 2009-11-08 18:32:46) [POST]
  Parameters: {"project_album"=>{"project_id"=>"20", "description"=>""}, "commit"=>"Submit", "authenticity_token"=>"GiYhxEPrdMkX7J403tzEToeQiXIgeoaAOaZtmlxJBEw="}
  ProjectAlbum Columns (0.6ms)   SHOW FIELDS FROM `project_albums`
20
  SQL (0.0ms)   BEGIN
  ProjectAlbum Create (0.2ms)   INSERT INTO `project_albums` (`created_at`, `photo_file_size`, `project_id`, `updated_at`, `photo_file_name`, `photo_content_type`, `photo_updated_at`, `description`) VALUES('2009-11-08 17:32:46', NULL, 20, '2009-11-08 17:32:46', NULL, NULL, NULL, '')
[paperclip] Saving attachments.
  SQL (2.1ms)   COMMIT
Redirected to http://localhost:3000/projects/20
Completed in 11ms (DB: 3) | 302 Found [http://localhost/project_albums]