roar-rails icon indicating copy to clipboard operation
roar-rails copied to clipboard

default_url_options as a configuration requirement

Open mikekelly opened this issue 11 years ago • 13 comments

@apotonick just a quick one.. working on a new API and wondering about the reasons why the default_url_options config option is a requirement and you weren't able to delegate this to Rails by default?

also - you dropped hal from the readme! :cry:

mikekelly avatar Nov 28 '13 15:11 mikekelly

Sounds like a good idea to delegate that per default.

No, eh, what do you mean? Did the roar-rails README ever contain docs about HAL? Or are you talking about the roar README?

apotonick avatar Nov 28 '13 22:11 apotonick

Sorry yeah the roar readme On 28 Nov 2013 22:25, "Nick Sutterer" [email protected] wrote:

Sounds like a good idea to delegate that per default.

No, eh, what do you mean? Did the roar-rails README ever contain docs about HAL? Or are you talking about the roar README?

— Reply to this email directly or view it on GitHubhttps://github.com/apotonick/roar-rails/issues/60#issuecomment-29487604 .

mikekelly avatar Nov 28 '13 22:11 mikekelly

Rewriting it, with first-level HAL chapter. Do you want me to put a photo of you (top-less?) into it? :grimacing:

apotonick avatar Nov 28 '13 22:11 apotonick

Do you mean to change this line from

Rails.application.config.representer.default_url_options or {}

to

Rails.application.config.representer.default_url_options or 
  Rails.application.config.action_controller.default_url_options

?

apotonick avatar Nov 28 '13 22:11 apotonick

You read my mind - this is exactly why I brought this up ;)

Just checking. I brought up the README for some example usage and couldn't spot any hal examples. Sad times. But they're coming back. Yay! Good times. On 28 Nov 2013 22:28, "Nick Sutterer" [email protected] wrote:

Rewriting it, with first-level HAL chapter. Do you want me to put a photo of you (top-less?) into it? [image: :grimacing:]

— Reply to this email directly or view it on GitHubhttps://github.com/apotonick/roar-rails/issues/60#issuecomment-29487692 .

mikekelly avatar Nov 28 '13 22:11 mikekelly

Yeah that's the sort of change I was getting at. I wondered if you had deliberately avoided this for some reason On 28 Nov 2013 22:35, "Nick Sutterer" [email protected] wrote:

Do you mean to change this linehttps://github.com/apotonick/roar-rails/blob/master/lib/roar/rails/url_methods.rb#L6from

Rails.application.config.representer.default_url_options or {}

to

Rails.application.config.representer.default_url_options or Rails.application.config.action_controller.default_url_options

?

— Reply to this email directly or view it on GitHubhttps://github.com/apotonick/roar-rails/issues/60#issuecomment-29487857 .

mikekelly avatar Nov 28 '13 22:11 mikekelly

Can you paste a raise Rails.application.config.action_controller.default_url_options.inspect in your running app?

apotonick avatar Nov 28 '13 22:11 apotonick

Not connected to the matrix right now but will try and remember tomorrow morning On 28 Nov 2013 22:46, "Nick Sutterer" [email protected] wrote:

Can you paste a raise Rails.application.config.action_controller.default_url_options.inspect in your running app?

— Reply to this email directly or view it on GitHubhttps://github.com/apotonick/roar-rails/issues/60#issuecomment-29488161 .

mikekelly avatar Nov 28 '13 22:11 mikekelly

The thing is, Rails.application.config.action_controller.default_url_options is nil in some of my apps. I just tested it. So defaulting the representer option to the action_controller directive wouldn't really help.

I now wonder how people actually use the Rails.application.config.representer.default_url_options in their apps? Do you guys copy the hash from action_controller.default_url_options or leave it blank, or....?

apotonick avatar Nov 28 '13 23:11 apotonick

nil here, I set Rails.application.config.representer.default_url_options as per the instructions I read at the time - but only use *_path helpers in my representers so far :heart:

jmartelletti avatar Nov 29 '13 00:11 jmartelletti

We serve different APIs at different endpoints, for example:

api.host.com accounting-api.host.com sales-api.host.com

The subdomain gets set as part of the representer.default_url_options, so that routes point to the correct controllers (there is some overlap in the resources exposed by the APIs).

We also define the host and protocol, but those aren't really significant (they don't change).

andresf avatar Nov 29 '13 00:11 andresf

@mikekelly Put a huge chapter about HAL into the README, retweet appreciated!

apotonick avatar Dec 10 '13 23:12 apotonick

And I still need to know your Rails.application.config.action_controller.default_url_options is in order to proceed with this issue.

apotonick avatar Dec 10 '13 23:12 apotonick