Skip to content

Instantly share code, notes, and snippets.

@daniel-rikowski
Created January 3, 2015 19:26
Show Gist options
  • Save daniel-rikowski/ca9709b3c5e7b951c9ba to your computer and use it in GitHub Desktop.
Save daniel-rikowski/ca9709b3c5e7b951c9ba to your computer and use it in GitHub Desktop.
Rails 4.2 cannot serialize certain strings when PostgreSQL is used
require 'yaml'
gem 'activerecord', '4.2.0'
require 'active_record'
require 'minitest/autorun'
require 'logger'
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: '...', username: '...', password: '...')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
# drop_table :posts rescue nil
create_table :posts do |t|
t.binary :attachment
end
end
class Post < ActiveRecord::Base
serialize :attachment
end
class BugTest < Minitest::Test
def test_serialize
Post.create!(attachment: '\/')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment