Permalink
Browse files

Added support for uploading and displaying an image attachment to the…

… scaffolding for the Image model.
  • Loading branch information...
endymion committed Jun 7, 2012
1 parent 7f29218 commit 358648128b63ecb4d17649c479b46130d5d336f1
Showing with 13 additions and 3 deletions.
  1. +9 −2 app/models/image.rb
  2. +3 −1 app/views/images/_form.html.erb
  3. +1 −0 app/views/images/show.html.erb
@@ -1,3 +1,10 @@
class Image < ActiveRecord::Base
# attr_accessible :title, :body
end
has_attached_file :attachment,
:storage => :s3,
:bucket => ENV['S3_BUCKET_NAME'],
:s3_credentials => {
:access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
attr_accessible :attachment
end
@@ -1,4 +1,4 @@
<%= form_for(@image) do |f| %>
<%= form_for(@image, :html => { :multipart => true }) do |f| %>
<% if @image.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@image.errors.count, "error") %> prohibited this image from being saved:</h2>
@@ -11,6 +11,8 @@
</div>
<% end %>
<%= f.file_field :attachment %>
<div class="actions">
<%= f.submit %>
</div>
@@ -1,5 +1,6 @@
<p id="notice"><%= notice %></p>
<%= image_tag @image.attachment.url %>
<%= link_to 'Edit', edit_image_path(@image) %> |
<%= link_to 'Back', images_path %>

0 comments on commit 3586481

Please sign in to comment.