bploetz / versionist

A plugin for versioning Rails based RESTful APIs.
MIT License
971 stars 51 forks source link

override subdomain #33

Closed jwoertink closed 11 years ago

jwoertink commented 11 years ago

I want to be able to share out public resource urls from within the API. I have an Event model, but when I do

event_url(@event, subdomain: nil)

I still get http://api.example.com/events/1

How do I tell it that I don't want the subdomain added on?

bploetz commented 11 years ago

Sorry, can you elaborate? Do you just want the path (i.e. /events/1)?

jwoertink commented 11 years ago

What I want is http://example.com/events/1 what I get is http://api.example.com/events/1 This happens regardless of having subdomain: nil or not.

bploetz commented 11 years ago

Are you saying this behaves as you expect when versionist is not in the picture, but does not work with versionist?

See this issue: https://github.com/rails/rails/issues/2025

jwoertink commented 11 years ago

Ah, I see what you mean. I'm on rails 2.3.11 now though. Do you know if this is still the same behavior?

bploetz commented 11 years ago

Versionist works for you on Rails 2.3? That's surprising, since the dependency is setup to only work in Rails 3 and above.

https://github.com/bploetz/versionist/blob/master/versionist.gemspec#L21

Anyhow, I've never played with that :subdomain flag (didn't even know it existed until I Googled "rails url_for subdomain" about 15 minutes ago when you opened this ticket :-)), so I'm not sure what the scoop is with Rails 2.3.

Anyhow, it sounds like this issue has nothing to do with versionist, and was simply a Rails question? If so, can you close this ticket?

jwoertink commented 11 years ago

haha. Yeah, versionist is working great for us on 2.3.11 :) Yeah, I guess it's probably just a weird rails thing with the subdomain constraint. I'll close this, but if anyone else comes along, I just used

event_url(@event, host: request.domain)

It's an ugly hack, but it works well enough for now.

Thanks!

bploetz commented 11 years ago

That's good to know. I'll add Rails 2.3 to the Travis testing matrix and see if it "just works". Thanks!

jwoertink commented 11 years ago

OH.. hahaha. I typed that wrong. oops. We are on 3.2.11 NOT 2.3.11.

bploetz commented 11 years ago

Ok, good, because after I sat back and thought about it, I was baffled at how this would even work.

Nothing to see here, move along....... ;-)