small medium large xlarge

12 Oct 2008, 16:07
Ed Murray (2 posts)

Hi, I have an application that consists of both a web app written in ROR and some ruby code. I have encrypted information in the database that my ruby code needs to access. The acts_as_secure works great within the Rails env, (thanks!). How can I read the data in the ruby environment? I’ve tried several things but the master_crypto_provider.rb file refers to some variables that are set when rails boots, (or so it appears.) So, I guess my question is: What do I need to set and how do I set it up to get this to work outside of Rails? MTIA! -Ed

14 Oct 2008, 15:50
Ed Murray (2 posts)

Bueller… Bueller?


I have this working however, I’m pretty sure there’s a better/more Railsy way. Any recommendations would be GREATLY apreciated. Here’s what I’ve done:

1) Changed the master_crypto_provider.rb file so it no longer refers to RAILS env vars. Any suggestions on how to do this more cleanly/flexibly??:

old: CONFIG = YAML.load_file(RAILS_ROOT + ‘/config/crypto.yml’)[ENV[‘RAILS_ENV’]].symbolize_keys

CONFIG = YAML.load_file(‘/home/pepper/monocle/config/crypto.yml’)[‘development’].symbolize_keys

2) Add the following to the load path in my ruby script. (Is there a more generally accepted way to handle vendor library stuff?):

$LOAD_PATH « ‘/home/pepper/monocle/lib’ $LOAD_PATH « ‘/home/pepper/monocle/vendor/plugins/acts_as_secure/lib’

3) Require the following in my ruby code: require ‘master_crypto_provider’ require ‘acts_as_secure’

Doing all this works but hard-coding the root path and my environment in my master_crypto_provider.rb file bugs me A LOT. Any recommendations would be greatly appreciated!

Thanks! -Ed

You must be logged in to comment