-
rails new SliceAutomation
-
add gem to Gemfile => gem 'paperclip'
-
bundle install
-
rails g scaffold screenshot title:string
-
rake db:migrate
-
rails generate paperclip screenshot picture
screenshot [model]
picture [field]
-
rake db:migrate
-
In Model:
class Screenshot < ActiveRecord::Base attr_accessible :title, :picture has_attached_file :picture, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png" end
-
In Views:
<%= form_for @screenshot, :url => screenshots_path, :html => { :multipart => true } do |f| %> <%= f.file_field :picture %> <% end %> <%= image_tag @user.avatar.url %> <%= image_tag @user.avatar.url(:medium) %> <%= image_tag @user.avatar.url(:thumb) %>
=============