Skip to content

Honor site path for has_one associations. - #333

Closed
elbowdonkey wants to merge 3 commits into
rails:masterfrom
elbowdonkey:buffington/honor_site_path_for_has_one
Closed

elbowdonkey wants to merge 3 commits into
rails:masterfrom
elbowdonkey:buffington/honor_site_path_for_has_one

Conversation

@elbowdonkey

Copy link
Copy Markdown

This fixes an issue where the site path would be incorrect for has_one relationships.

When the models were defined as:

class Order < ActiveResource::Base
  self.site = "http://example.com/api/v1"
  has_one :shipping_label
end

class ShippingLabel < ActiveResource::Base
  self.site = "http://example.com/api/v1"
end

The /api/v1 portion of site would be stripped.

When doing:

Order.find(1).shipping_label

The URL used when doing a get for shipping_label would be http://example.com/orders/1/shipping_label.json, rather than http://example.com/api/v1/orders/1/shipping_label.json.

@rails-bot

rails-bot Bot commented Sep 2, 2020

Copy link
Copy Markdown

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 team are limited, and so we are asking for your help.

If it is an issue and you can still reproduce this error on the master branch,
please reply with all of the information you have about it in order to keep the issue open.

If it is a pull request and you are still interested on having it merged please make sure it can be merged clearly.

Thank you for all your contributions.

@rails-bot rails-bot Bot added the stale label Sep 2, 2020
@elbowdonkey

Copy link
Copy Markdown
Author

All of the above is still relevant and likely mergeable. Perhaps it'd be a good idea to increase the span of time rails-bot marks things as stale?

@rails-bot rails-bot Bot removed the stale label Sep 2, 2020
@rails-bot

rails-bot Bot commented Dec 1, 2020

Copy link
Copy Markdown

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 team are limited, and so we are asking for your help.

If it is an issue and you can still reproduce this error on the master branch,
please reply with all of the information you have about it in order to keep the issue open.

If it is a pull request and you are still interested on having it merged please make sure it can be merged clearly.

Thank you for all your contributions.

@rails-bot rails-bot Bot added the stale label Dec 1, 2020
@rails-bot rails-bot Bot closed this Dec 8, 2020
@rafaelfranca rafaelfranca reopened this Dec 9, 2020
@rails-bot rails-bot Bot removed the stale label Dec 9, 2020
Comment thread test/cases/base_test.rb
def test_has_one_finder_uses_site_path
ShippingLabel.site = "http://37s.sunrise.i:3000/api/v1"
Order.site = "http://37s.sunrise.i:3000/api/v1"
Order.send(:has_one, :shipping_label)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is changing the global state so I think we should move all those calls to the class definition in the fixtures

@rails-bot

rails-bot Bot commented Mar 9, 2021

Copy link
Copy Markdown

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 team are limited, and so we are asking for your help.

If it is an issue and you can still reproduce this error on the master branch,
please reply with all of the information you have about it in order to keep the issue open.

If it is a pull request and you are still interested on having it merged please make sure it can be merged clearly.

Thank you for all your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants