Class: Bently::Paperclip

Inherits:
RailsRecipe show all
Defined in:
lib/bently/recipe/paperclip.rb

Constant Summary

Constants inherited from RubyRecipe

RubyRecipe::GEMFILE

Instance Method Summary collapse

Methods inherited from RailsRecipe

#generate, #migrate

Methods inherited from RubyRecipe

#bundle, #gem, #gem_group

Methods inherited from Recipe

#append, breakdown, category, #code, #create, description, homepage, #insert, #modify, #operate, #operations, #prepend, #remove, #requirement, #run, #say, title, #todo, #usage, version, #warn

Constructor Details

#initializePaperclip

Returns a new instance of Paperclip.



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
# File 'lib/bently/recipe/paperclip.rb', line 8

def initialize
  requirement 'Install ImageMagick. For Mac OS X use Homebrew: `brew install imagemagick`'
  requirement 'Source ImageMagick path (`which convert`) in development environment file. For example:'

  say '  Paperclip.options[:command_path] = "/usr/local/bin/"', ''
  gem 'paperclip', "~> 3.0"
  bundle

  todo 'Sample model:'
  say '  class User < ActiveRecord::Base', ''
  say '    attr_accessible :avatar', ''
  say '    has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"', ''
  say '  end', ''
  todo 'Sample migration generator:'
  say '  rails generate paperclip user avatar', ''
  todo 'Sample edit/new views:'
  say '  <%= form_for @user, :url => users_path, :html => { :multipart => true } do |form| %>',''
  say '    <%= form.file_field :avatar %>',''
  say '  <% end %>',''
  todo 'Sample controller:'
  say '  def create',''
  say '    @user = User.create( params[:user] )',''
  say '  end',''
  todo 'Sample show view:'
  say '  <%= image_tag @user.avatar.url %>', ''
  say '  <%= image_tag @user.avatar.url(:medium) %>', ''
  say '  <%= image_tag @user.avatar.url(:thumb) %>', ''
end