This project is archived and is in readonly mode.

#4348 ✓ stale
Jamis Buck

Supporting singleton resources in ActiveResource

Reported by Jamis Buck | April 8th, 2010 @ 07:24 PM

Currently, if you indicate that a resource is a singleton in your routes, there is no way (short of monkeypatching ActiveResource) to access that resource via ActiveResource.

This patch adds support for a "singleton" macro, that lets you declare that a particular model maps to a singleton resource:

  class Status < ActiveResource::Base
    singleton
    # ...
  end

You can then access that singleton resource via a bare "find" call (without arguments):

  current_status = Status.find
  current_status.description = "Code red!"
  current_status.save

etc.

The attached patch includes tests.

Comments and changes to this ticket

Create your profile

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

Tickets have moved to Github

The new ticket tracker is available at https://github.com/rails/rails/issues

Shared Ticket Bins

Attachments

Pages