Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Namespacing for activeresource

#2069

If you have an Client object in your Rails app and you want to use ActiveResource to get Clients from another application, then these Client objects have to have exactly the same attributes or ActiveResource will break. Because in a real world situation a lot of people call models in their application by the same name, sometimes you do not want ActiveResource to assume this behaviour.

To fix this I added this namespace patch. When a namespace is defined, the ActiveResource resourcename will not be Client, but NameSpaceClient. This will make ActiveResource fall back to it's default 'unknown source' behaviour, making it possible to get remote resources with the same name.

Reported by Bart ten Brinke · February 25th, 2009 @ 10:25 AM

State: stale
Milestone: 3.x
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. José Valim
    José Valim
    • Tag changed from activeresource, class, name, namespacing to activeresource, patch

    Great! +1

    February 25th, 2009 @ 03:28 PM

  2. Federico Builes
  3. Bart ten Brinke
    Bart ten Brinke
    • Tag changed from activeresource, patch to activeresource, patch, verified

    It would be really nice if this went in 2.3, together with the XML parser upgrades. It would really make activeresource usable for a lot of people.

    March 10th, 2009 @ 07:11 PM

  4. Bart ten Brinke
  5. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to open

    Good idea, but the 'namespace' name is too generic.

    How about localizing the unknown-constant lookup to a single method that subclasses can override to implement whatever behavior they like.

    May 19th, 2009 @ 10:03 PM

  6. Bart ten Brinke
    Bart ten Brinke

    Have you got a better suggestion then namespace? Localizing the unkown constant lookup via a method missing is pretty much what is happening in AR right now. Refactoring that is a good idea but goes a lot further then this patch :)

    May 19th, 2009 @ 11:16 PM

  7. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  8. Dan Pickett
    Dan Pickett
    • Tag changed from activeresource, patch, verified to activeresource, bugmash, patch, verified

    May 9th, 2010 @ 05:59 PM

  9. Santiago Pastorino
    Santiago Pastorino
    • Importance changed from to

    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.

    February 2nd, 2011 @ 05:02 PM

  10. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 05:02 PM