You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Singletons: Default collection_name to singleton_name
When declaring a resource as a "singleton" (through including the
`ActiveResource::Singleton` module), ensure that subsequent calls to
class-level custom methods (through the `get`, `post`, `put`, `patch`,
and `delete` class and instance methods) use the singleton name by
default.
```ruby
Inventory.get(:report, product_id: 1) # => GET /products/1/inventory/report.json
Inventory.delete(:reset, product_id: 1) # => DELETE /products/1/inventory/reset.json
```
Similarly, instance-level custom methods (through the same `get`,
`post`, `put`, `patch`, and `delete` style methods) use the singleton
name **and** omit the resource ID from the path.
```ruby
inventory = Inventory.find(params: { product_id: 1 }) # => GET /products/1/inventory.json
inventory.get(:report) # => GET /products/1/inventory/report.json
inventory.delete(:reset) # => DELETE /products/1/inventory/reset.json
```
When a `collection_name` is explicitly configured, use that value
instead of the `singleton_name` default.
0 commit comments