Ruby Findings

digging for gems

On the fly field encryption/decryption

Posted by Art Green Sat, 05 Jan 2008 20:52:00 GMT

"ActsAsSecure adds an ability to store ActiveRecord model's fields encrypted in a DB. When a model is marked with acts_as_secure, the :binary type fields are recognized as needed to be stored encrypted. The plugin does before_save/after_save/after_find encryption/decryption thus making it transparent for a code using secured models.

The plugin supports a master key approach as well as individual records encryption keys. It does not contain any crypto provider but allows to plug in any external one as long as it supports encrypt/decrypt methods."

http://revolutiononrails.blogspot.com/2007/04/plugin-release-actsassecure.html

The site has some other goodies too.

Posted in | no comments |

Using Active Record from outside of Rails

Posted by Art Green Sun, 14 Oct 2007 16:26:00 GMT

I’ve read a bunch of conflicting advice on how to use active record models defined in a Rails application from outside Rails.

The following is the result of experimenting with others’ advice plus my own digging around:

require 'rubygems'
require 'active_record'
require '/path/to/rails/config/environment'

This should allow you to use your Rails models just like you would in a Rails controller:

#!/usr/local/bin/ruby

require 'rubygems'
require 'active_record'
require '/var/www/railsapp/config/environment'

m = MyModel.new
m.find_all.each { |row|
  puts row.some_column
}

Posted in , | 1 comment |


html>