This project is archived and is in readonly mode.

#6171 open
Thilo Utke

ActiveResource: prefix attributes that are mass assigned are not readable and serializable.

Reported by Thilo Utke | December 15th, 2010 @ 02:41 PM

When I initialize a resource that uses prefixes I expect that also the attribute that is used as prefix shows up when i serialize the resource.

Failing Test:

class Foo < ActiveResource::Base = "" end

assert_equal => 1).as_json, {'foo' => {'bar_id' => 1}} #right now you will get {'foo' => {}}
assert_equal => 1).bar_id, 1 # now method error.

The root of the problem is located at ActiveResoure::Base split_options Line:922 (ActiveResource 3.0.3). Maybe it is just a bad convention, and prefixes should be passed more explicitly to avoid such surprises.

Comments and changes to this ticket

  • rails

    rails March 16th, 2011 @ 12:00 AM

    • State changed from “new” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • rails

    rails March 16th, 2011 @ 12:00 AM

    • State changed from “open” to “stale”
  • Pierre Lancien

    Pierre Lancien March 18th, 2011 @ 05:09 PM

    I made a patch for this issue two months ago but I forgot to submit it...
    I checked, the issue is still here in the latest Rails version. So here is my patch.

    Warning - one of the tests I added triggers the bug I previously mentioned and fixed here :

    (I still don't know how to apply the "patch" tag here in lighthouse, so if someone reads this, please create the tag or tell me how to do it)

  • Matt Jones

    Matt Jones March 18th, 2011 @ 05:25 PM

    • State changed from “stale” to “open”
    • Importance changed from “” to “Low”
  • Evgeniy Dolzhenko

    Evgeniy Dolzhenko March 19th, 2011 @ 07:57 AM

    I'm +1 on this getting merged, currently in our ActiveResource models we have to do things like

    class Foo < ActiveResource::Base
    def bar_id


    end end

    this patch would solve that (+ include the attributes in serialized version of resource)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>