Open abuzzany opened 4 years ago
Hi everyone,
I have an active called TaxableEntity that has the next attr_encryped attribute:
TaxableEntity
attr_encrypted( :sat_password, key: Rails.configuration.creds.fetch(:SECRET_KEY_BASE), attribute: "encrypted_sat_password", algorithm: "aes-256-cbc", mode: :single_iv_and_salt, insecure_mode: true )
Currently I am using the attr_encrypted from 3.0.3 gem and It works correctly. The problem comes when I bump the gem to 3.10 version. When I use the method as_json on the active model object I get the next error:
attr_encrypted from 3.0.3
as_json
irb(main):007:0> t2 = TaxableEntity.select(:id).find(1) TaxableEntity Load (0.4ms) SELECT "taxable_entities"."id" FROM "taxable_entities" WHERE "taxable_entities"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]] => #<TaxableEntity id: 1, sat_password: nil> irb(main):008:0> t2.as_json Traceback (most recent call last): 1: from (irb):8 ActiveModel::MissingAttributeError (missing attribute: encrypted_sat_password)
but It only happens when use before a select method, without select it works correctly
select
#<TaxableEntity id: 1, rfc: "TEST010203001", created_at: "2020-06-15 19:56:43", updated_at: "2020-06-15 19:56:43", legal_name: "Resuelve PF", account_holder_id: 3, encrypted_sat_password: nil, tax_classification: "business_activity", employer_registration: "A2410589123", customer_token: nil, user_id: nil, sent_statement: false, service_comments: nil, accountant_comments: nil, zendesk_id: nil, curp: nil, accounting_settings: nil, valid_credentials: true, complexity: nil, paybook_user: nil, legal_type: "individual", status: "demo", active: true, old_services: nil, postal_code: "05200", generation: nil, last_downloaded_invoice_issue_date: nil, last_crawler: nil, sales_comments: nil, fiscal_status: nil, uses_otp: false, sales_user_id: nil, customer_service_user_id: nil, accounting_status: nil, payment_reference: nil, closing_date: nil, conekta: false, expired_payments: 0, migrated_entity: false, sat_password: nil> irb(main):011:0> t1.as_json => {"id"=>1, "rfc"=>"TEST010203001", "created_at"=>Mon, 15 Jun 2020 14:56:43 CDT -05:00, "updated_at"=>Mon, 15 Jun 2020 14:56:43 CDT -05:00, "legal_name"=>"Resuelve PF", "account_holder_id"=>3, "encrypted_sat_password"=>nil, "tax_classification"=>"business_activity", "employer_registration"=>"A2410589123", "customer_token"=>nil, "user_id"=>nil, "sent_statement"=>false, "service_comments"=>nil, "accountant_comments"=>nil, "zendesk_id"=>nil, "curp"=>nil, "accounting_settings"=>nil, "valid_credentials"=>true, "complexity"=>nil, "paybook_user"=>nil, "legal_type"=>"individual", "status"=>"demo", "active"=>true, "old_services"=>nil, "postal_code"=>"05200", "generation"=>nil, "last_downloaded_invoice_issue_date"=>nil, "last_crawler"=>nil, "sales_comments"=>nil, "fiscal_status"=>nil, "uses_otp"=>false, "sales_user_id"=>nil, "customer_service_user_id"=>nil, "accounting_status"=>nil, "payment_reference"=>nil, "closing_date"=>nil, "conekta"=>false, "expired_payments"=>0, "migrated_entity"=>false, "sat_password"=>nil}
Can you help me?
Thanks
I'm having the same problem here
Hi everyone,
I have an active called
TaxableEntity
that has the next attr_encryped attribute:Currently I am using the
attr_encrypted from 3.0.3
gem and It works correctly. The problem comes when I bump the gem to 3.10 version. When I use the methodas_json
on the active model object I get the next error:but It only happens when use before a
select
method, withoutselect
it works correctlyCan you help me?
Thanks