This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prawn::Document.generate "test.pdf" do | |
stroke_horizontal_rule | |
text "Some text\nwith a line break" | |
stroke_horizontal_rule | |
move_down 10 | |
stroke_horizontal_rule | |
text "Some <b>bold</b> text<br />with a line break" | |
stroke_horizontal_rule | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- has_attachment :content_type => :image, | |
- :thumbnails => { | |
- :thumb => [80,80], | |
- :small => '320x320>' | |
- }, | |
- :storage => :s3, | |
- :s3_access => :private | |
+ | |
+ has_attached_file :photo, | |
+ :styles => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ChangePhotoFromAttachmentFuToPaperclip < ActiveRecord::Migration | |
def self.up | |
#Reorganise the actual photos on AWS to suit the RWS/Paperclip schema | |
#Rename attachement_fu columns to paperclip convention | |
rename_column :photos, :filename, :photo_file_name | |
rename_column :photos, :content_type, :photo_content_type | |
rename_column :photos, :size, :photo_file_size | |
#Remove non-paperclip columns | |
remove_column :photos, :width |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'right_aws' | |
namespace :utils do | |
namespace :attachments do | |
task :initialize_s3 => :environment do | |
s3_config = YAML.load_file(File.join(File.dirname(__FILE__), '/../../config/amazon_s3.yml')) | |
s3_config = s3_config[RAILS_ENV].to_options | |
@s3 = RightAws::S3.new(s3_config[:access_key_id], s3_config[:secret_access_key]) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def tabalize(headings, justifications = nil, out = STDOUT) | |
raise ArgumentError.new('only works on an array of arrays') if size > 0 && ![0].is_a?(Array) | |
raise ArgumentError.new('headings, justifications and array elements must all have the same number of elements') if size > 0 && (headings.size != [0].size) && (!justifications.nil? && (headings.size != justifications.size)) | |
sizes = Array.new(headings.size, 0) | |
headings.each_with_index do |h,i| | |
sizes[i] = [sizes[i], h.to_s.length].max | |
end | |
each do |row| | |
row.each_with_index do |e, i| |
NewerOlder