Repository navigation
has_one fallback works when target is not a Singleton - #100
Merged
guilleiguaran merged 1 commit intoJan 31, 2014
Merged
Conversation
As documented: > if a Product class `has_one :inventory` calling `Product#inventory` > will generate a request on /products/:product_id/inventory.json. This was implemented in #15, but only implemented and tested for a true Singleton target. It should also work when the target model does not actually include Singleton, e.g. a Post has one Author.
guilleiguaran
added a commit
that referenced
this pull request
Jan 31, 2014
…ngleton has_one fallback works when target is not a Singleton
guilleiguaran
added a commit
that referenced
this pull request
Nov 30, 2015
…ngleton has_one fallback works when target is not a Singleton
denis
added a commit
to denis/activeresource
that referenced
this pull request
Oct 6, 2018
Consider a simple case when URLs are prefixed with API version:
class ApplicationResource < ActiveResource::Base
self.site = "https://api.quovo.com/v3"
self.include_format_in_path = false
end
class Connection < ApplicationResource
has_one :sync
end
class Sync < ApplicationResource
end
`connection = Connection.find(1)` fetches data from `https://api.quovo.com:443/v3/connections/1`.
`connection.sync` is expected to fetch from `https://api.quovo.com:443/v3/connections/1/sync` but before this fix it tries to fetch it from `https://api.quovo.com:443/connections/1/sync` (missing `/v3/` prefix) that isn’t correct.
I believe that the bug was introduced in rails#100.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As documented:
This was implemented in #15, but only implemented and tested for a true Singleton target. It should also work when the target model does not actually include Singleton, e.g. a Post has one Author.
Forgive me for being unfamiliar with the test suite -- I didn't immediately grok why I needed to add the
@postmock with an explicitAcceptheader. If someone can clarify for me I'll clean up as appropriate.