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

185 Views Asked by At

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

2

There are 2 best solutions below

0
Michael Moulsdale On

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
3
Raj On

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