Skip to content

Instantly share code, notes, and snippets.

@tamc
Created July 3, 2012 05:13
Show Gist options
  • Select an option

  • Save tamc/3037822 to your computer and use it in GitHub Desktop.

Select an option

Save tamc/3037822 to your computer and use it in GitHub Desktop.
# Setup
require 'active_record'
require 'paperclip'
require 'sqlite3'
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => ':memory:')
class AddTables < ActiveRecord::Migration
include Paperclip::Schema
def change
create_table :things do |t|
t.attachment :file
end
end
end
AddTables.migrate :up
class Thing < ActiveRecord::Base
include Paperclip::Glue
has_attached_file :file
end
# Test
original = Thing.create
copy = Thing.new
copy.file = original.file
copy.save
# Unexpectedly, the above results in a can't convert nil into String (TypeError) from paperclip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment