gem 'papermill' generate :papermill_table, "PapermillMigration" generate :papermill_assets generate :scaffold, "article title:string" rake "db:migrate" file "app/models/article.rb", <<-END class Article < ActiveRecord::Base validates_presence_of :title papermill :thumbnail => {:width => 100, :height => 75} # catch-all for non-specified associations, will create assets/asset methods. papermill :image_gallery, :class_name => ImageAsset, :images_only => true, :thumbnail => {:width => 75, :height => 100} # image_gallery association (set with define_method) end END file "app/models/image_asset.rb", <<-END class ImageAsset < PapermillAsset validates_attachment_content_type :file, :content_type => ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/png', 'image/gif'] end END file "app/views/articles/edit.html.erb", <<-END
<%= f.label :title %>
<%= f.text_field :title %>
<%= f.label :image_gallery %>
<%= f.images_upload(:image_gallery) %>
<%= f.label :my_other_image %>
<%= f.image_upload(:my_other_image) %>
<%= f.label :my_assets %>
<%= f.assets_upload(:my_assets) %>
<%= f.label :my_other_asset %>
<%= f.asset_upload(:my_other_asset) %>
<%= f.submit 'Send' %>
<% end %> END file "app/views/articles/show.html.erb", <<-ENDTitle: <%=h @article.title %>
<% @article.image_gallery.each do |image| %> <%= link_to(image_tag(image.url("100x100#")), image.url) %> <% end %>
<% image = @article.asset(:my_other_image) %> <%= link_to(image_tag(image.url("100x100#")), image.url) if image %>
<% asset = @article.asset(:my_other_asset) %> <%= link_to(asset.name, asset.url) if asset %>
<%= link_to 'Edit', edit_article_path(@article) %> | <%= link_to 'Back', articles_path %> END file "app/views/layouts/application.html.erb", <<-END