GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: yet another gallery application done in Rails
Clone URL: git://github.com/kingmt/gallery.git
update for attachment_fu
kingmt (author)
Fri Jul 25 09:43:08 -0700 2008
commit  f68779c81829283546c072c7c8b5f810c735b384
tree    3faef4cfeebfe2ecfcace1b057d9dae0be29dce1
parent  689e75a5ad1c3edec59dbbbde08b55d643b68476
...
5
6
7
8
 
...
5
6
7
 
8
0
@@ -5,4 +5,4 @@ tmp
0
 nbproject/*
0
 data
0
 coverage
0
-
0
+public/pictures/*
...
1
2
 
 
 
 
 
 
 
 
 
3
...
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1,3 +1,12 @@
0
 class Picture < ActiveRecord::Base
0
   belongs_to :album
0
+
0
+ has_attachment :content_type => :image,
0
+ :storage => :file_system,
0
+ :resize_to => '640x400',
0
+ :max_size => 1.megabyte,
0
+ :thumbnails => {:thumb => '100x100', :geometry => 'x50'}
0
+
0
+ validates_as_attachment
0
+
0
 end
...
3
4
5
6
7
8
9
10
11
12
13
 
 
 
 
 
 
 
14
15
16
...
3
4
5
 
 
 
 
 
 
 
 
6
7
8
9
10
11
12
13
14
15
0
@@ -3,14 +3,13 @@
0
 <% form_for([@album, @picture]) do |f| %>
0
   <%= f.error_messages %>
0
 
0
- <p>
0
- <%= f.label :path %><br />
0
- <%= f.text_field :path %>
0
- </p>
0
- <p>
0
- <%= f.label :description %><br />
0
- <%= f.text_area :description %>
0
- </p>
0
+ <table>
0
+ <tr>
0
+ <td><%= image_tag @picture.public_filename %></td>
0
+ <td><%= f.label :description %><br />
0
+ <%= f.text_area :description %></td>
0
+ </tr>
0
+ </table>
0
   <p>
0
     <%= f.submit "Update" %>
0
   </p>
...
1
 
2
3
4
5
6
7
8
9
10
11
12
 
13
14
15
16
17
18
...
 
1
2
3
4
5
6
 
7
8
9
10
 
11
12
 
 
13
14
15
0
@@ -1,18 +1,15 @@
0
-<h1>Listing pictures</h1>
0
+<h1>Listing pictures in <%=h @album.name %> album</h1>
0
 
0
 <table>
0
   <tr>
0
     <th>Path</th>
0
     <th>Description</th>
0
- <th>Album</th>
0
   </tr>
0
 
0
 <% for picture in @pictures %>
0
   <tr>
0
- <td><%=h picture.path %></td>
0
+ <td><%= link_to image_tag(picture.public_filename(:thumb)), picture.public_filename %></td>
0
     <td><%=h picture.description %></td>
0
- <td><%=h picture.album_id %></td>
0
- <td><%= link_to 'Show', album_picture_path(@album,picture) %></td>
0
     <td><%= link_to 'Edit', edit_album_picture_path(@album,picture) %></td>
0
     <td><%= link_to 'Destroy', album_picture_path(@album,picture), :confirm => 'Are you sure?', :method => :delete %></td>
0
   </tr>
...
1
2
3
 
4
5
6
7
8
 
 
9
 
10
11
12
...
1
2
 
3
4
5
6
 
 
7
8
9
10
11
12
13
0
@@ -1,12 +1,13 @@
0
 <h1>New picture</h1>
0
 
0
-<% form_for([@album, @picture]) do |f| %>
0
+<% form_for([@album, @picture], :html => { :multipart => true }) do |f| %>
0
   <%= f.error_messages %>
0
 
0
   <p>
0
- <%= f.label :path %><br />
0
- <%= f.text_field :path %>
0
+ <label for="picture">Upload A Picture:</label>
0
+ <%= f.file_field :uploaded_data %>
0
   </p>
0
+
0
   <p>
0
     <%= f.label :description %><br />
0
     <%= f.text_area :description %>
...
1
2
3
4
5
 
6
7
8
9
10
11
12
13
14
15
16
17
18
...
 
 
 
 
 
1
2
3
4
5
6
 
 
 
 
 
7
8
9
0
@@ -1,18 +1,9 @@
0
-<p>
0
- <b>Path:</b>
0
- <%=h @picture.path %>
0
-</p>
0
-
0
+<%= image_tag @picture.public_filename %>
0
 <p>
0
   <b>Description:</b>
0
   <%=h @picture.description %>
0
 </p>
0
 
0
-<p>
0
- <b>Album:</b>
0
- <%=h @picture.album_id %>
0
-</p>
0
-
0
 
0
 <%= link_to 'Edit', edit_album_picture_path(@album, @picture) %> |
0
 <%= link_to 'Back to index', album_pictures_path(@album) %>

Comments

    No one has commented yet.