Open nesrual opened 9 years ago
It's been a while... :)
but since the issue is still open, I think the problem is not with Rack. I think the solution to your problem is to first require active_record
and active_model
before attr_encrypted
.
require 'active_record'
require 'active_model'
require 'attr_encrypted'
The ActiveRecord adapter will load only if ActiveRecord::Base
was defined.
I am using attr_encrypted from a rack/ruby script and it seems like there is some weird issue with ActiveRecord and attr_encrypted.
attr_encrypted works fine and the correct values are set in the object. The object is validated using ActiveModel, however when saving the object the values set by attr_encrypted are cleared (nil).
It works fine using the console and the object is saved to the database.
Using Ruby 2.2.2, Rails 4.2.2, PostgreSQL
Code example below to replicate the problem: