11

This warning shows up for me (for everyone) in the majority of controller tests. I know its just a warning...for now...until 5 is released. I am unsure what I need to change to comply with this deprecation. What has changed with serialized_attributes? Id like to make this warning go away and improve my code in prep for 5.0...but unsure how to proceed. Thanks.

update

When hitting a standard update action from a controller test...I get the error:

@document.update_attributes(document_params)

in the test (condensed for this example):

    before do
      @document = documents(:drivers_license)
    end

    def valid_params
      { name: 'Passport' }
    end

    it "must update document" do
      put :update, id: @document, document: valid_params
      assert_redirected_to documents_path
    end

This test passes, but now in rails 4.2 puts the error: DEPRECATION WARNING: serialized_attributes is deprecated without replacement, and will be removed in Rails 5.0."

So, in this example...are the serialized_attributes "{ name: 'Passport' }"?

hellion
  • 4,602
  • 6
  • 38
  • 77
  • 1
    Knowing how to fix it, would depend on how you're using it. – sevenseacat Dec 23 '14 at 04:13
  • 1
    Just because something was thought to be no longer good for the community as a whole does not mean that it is not good for you. You could extend your ActiveRecord module with the method from https://github.com/rails/rails/blob/4-2-stable/activerecord/lib/active_record/attribute_methods/serialization.rb which contains the serialized_attributes. However, if this deprecation warning is coming from a gem that you're using and not from your code, you will most likely want to open a ticket/issue with the authors of that gem so that can accommodate future versions of Rails. – kobaltz Dec 23 '14 at 04:29
  • 1
    The deprecation is discussed in this issue: https://github.com/rails/rails/pull/15704. The warning comes across as a bit surprising and should probably include at least a reference to the Rails upgrading guide. – mahemoff Feb 19 '15 at 12:24

1 Answers1

9

Are you perhaps using the paper_trail gem? If so, see issue #416 in that project.

smathy
  • 26,283
  • 5
  • 48
  • 68
  • 1
    i am using paper_trail. Thanks for that. – hellion Jan 29 '15 at 02:09
  • 1
    Upgrading to paper_trail's v4 beta (see that issue) removed the warnings for me. @hellion please accept this answer if it fixed it for you. Although this is a generic Rails update, probably most developers in reality will encounter this because of a handful of gems like paper_trail and rails_admin. – mahemoff Feb 19 '15 at 12:22