0

Hi I am using symmetric encryption (This one) gem to encrypt some fields. I have generated all the keys and followed all the steps given in it. But When I am trying to save data on my server it throws error on these lines

 attr_encrypted :latitude
 attr_encrypted :longitude

Error is

undefined method `encrypted_latitude' for #<Location:0x007f574a4eef50>

I have checked types, steps for gem and all looks fine. Any idea what I am missing ...all works when I removed these lines from model. In Addition I have added attr_accessible for both fields and protected_attributes gem to make attr_accessible work

Any idea where I went wrong..Thanks

JNI_OnLoad
  • 5,472
  • 4
  • 35
  • 60

2 Answers2

0

Looks like you may not have got a single instance of location. Do you have first at the end of the query?

i.e.

lat = Latitude.where( query ).first
Michael Moulsdale
  • 1,488
  • 13
  • 34
0

The error means that the column named encrypted_latitude is not available in your locations table.

From the doc:

class User < ActiveRecord::Base
  # Requires table users to have a column called encrypted_bank_account_number
  attr_encrypted :bank_account_number
Raj
  • 22,346
  • 14
  • 99
  • 142
  • that means I need to add encrypted_latitude field in table ..which does not make sense coz I want to encrypt those field not to keep both normal and encrypted in different fields...in same table – JNI_OnLoad May 20 '14 at 07:51
  • rename latitude field to encrypted_latitude. normal value will not be stored. – Raj May 20 '14 at 07:54
  • ahh..ok thanks ...I try that and accepts answer ...:) – JNI_OnLoad May 20 '14 at 07:55