README.md in tori-0.0.8 vs README.md in tori-0.0.9

- old
+ new

@@ -72,9 +72,51 @@ photo.image.read #=> image bin photo.image.exist? #=> exist check photo.image.name #=> filename ``` +# Attach example + +Two image file upload to backend example. +defined method by `tori` method can define a key name for each by block. + +```ruby +class Photo < ActiveRecord::Base + tori :original_image do |model| + "#{model.class}/original/#{model.original_filename}" + end + + tori :striped_image do |model| + "#{model.class}/striped/#{model.striped_filename}" + end +end + +class PhotoController < ApplicationController + def create + original = params[:file] + Tempfile.open("striped") { |striped| + # image processing example + MiniMagick::Tool::Convert.new { |c| + c.strip + c << original.path + c << striped.path + } + + # create record + photo = Photo.create + + # set image file to model + photo.original_image = original + photo.striped_image = striped + + # write image file to backend + photo.original_image.write + photo.striped_image.write + } + end +``` + + # Custom configure example ```ruby # Save to S3 bucket. require 'tori/backend/s3'