Pål Bergström wrote:
> Brian Mr wrote:
>> Pål Bergström wrote:
> 
>> Simply add a public method to the model that returns the unendrypted 
>> version.  The method will not map to an actual column in the db, but to 
>> the controller it will appear just like any other colum.
>> 
>> e.g.
>> 
>> def myattribute
>>   Crypto.decrypt(column)
>> end
> 
> I don't understand all the way. Probably a stupid question but could you 
> be more specific with what you mean with"myattribute"? Is that the 
> column name or?

It's not a column, it's just a method.  ActiveRecord is just a Ruby 
Class, so you can add your own methods.  e.g. To use the method in a 
controller:

x = myrecord.find....
y = myrecord.myattribute

y now holds the unencypted value.

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to