I have 2 models:
class Invoice < ActiveRecord::Base
has_many :invoice_items
accepts_nested_attributes_for :invoice_items, :allow_destroy => true
end
class InvoiceItem < ActiveRecord::Base
attr_accessor :encryption_key
belongs_to :invoice
end
The columns for invoice items are encrypted and I use an encryption key that comes from a session. I don't want this key stored on the server or in any other model.
From the controller:
params[:invoice][:invoice_items_attributes].each_value {
|v| v.merge!(:encryption_key => session['access_key'])
}
@invoice = Invoice.new(params[:invoice])
This puts the key into the attributes list fine but it is then not passed to the InvoiceItems model when creating an invoice...
Any pointers on how to get this working would be great.