If you do not have an s3 account, go here:
http://aws.amazon.com/s3/
You need to add this to your contact model:
application / models / contact.rb
has_attached_file :picture, :styles => {:large => "275x450>"}, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => "appname/:attachment/:style/:id.:extension"
Make sure the application name is your rails application name on heroku. And make sure you rename the image according to what you called your image.
Then you need the configuration file in config/s3.yml .
development: bucket: bucked_name access_key_id: key secret_access_key: secret production: bucket: bucked_name access_key_id: key secret_access_key: secret
Make sure you understand the key and the secret correctly.
In your gem file, make sure you install these stones:
gem "aws-s3", :require => "aws/s3" gem "paperclip"
Then in your form you will need a file field and declare a multipart form:
<% form_for(@contact, :html => {:multipart => true}) do |f| %> <p><%= f.file_field :picture %></p> <% end %>
And that should do it. If you do not have an s3 account, go here:
http://aws.amazon.com/s3/
You need to add this to your contact model:
application / models / contact.rb
has_attached_file :picture, :styles => {:large => "275x450>"}, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => "appname/:attachment/:style/:id.:extension"
Make sure the application name is your rails application name on heroku. And make sure you rename the image according to what you called your image.
Then you need the configuration file in config/s3.yml .
development: bucket: bucked_name access_key_id: key secret_access_key: secret production: bucket: bucked_name access_key_id: key secret_access_key: secret
Make sure you understand the key and the secret correctly.
In your gem file, make sure you install these stones:
gem "aws-s3", :require => "aws/s3" gem "paperclip"
Then in your form you will need a file field and declare a multipart form:
<% form_for(@contact, :html => {:multipart => true}) do |f| %> <p><%= f.file_field :picture %></p> <% end %>
Then write your contact with the image. Did you say you use rails 3?
So, in your contact model:
class Contact << ActiveRecord::Base before_save :mail_user def mailer_user ContactMailer.contact_notification(@user).deliver end end
Then in your mail program (assuming you are on Rails 3):
class ContactMailer < ActionMailer::Base default :from => " sam@codeglot.com " def contact_notification(@user) @subscription = "test" @url = "test" mail(:to => " test@test.com ", :subject => "Test") end end
So, in your postal view, you need to include the image tag like this:
<%= image_tag(@contact.picture(:small)) %>
Then you just need to send an email after creating the contact and enable the attachment.