I'm not sure if you are still looking for the answer, but as I just went through this episode and I am going to use a similar functionality with subdomains, as you need, I guess I know the answer for your question.
First of all, you can not expect to have in return of _path helper methods anything with the host. Instead use the _url helper methods. That will lead you into the 2nd point.
Based on the root_url(:subdomain => @blog.name) used in the episode and thanks to the overridden url_for helper you can use the subdomain key in the options of any _url helper methods. Here we go:
I think you could also override blogs_articles_url helper method to be consistent with using nested resources way of creating urls. The below code is just an idea and should be re-factored to use all functionality of blogs_articles_url helper method, but for simplicity I put the below.
ruby
defblogs_articles_url(options = nil)
if options.kind_of?(Blog)
articles_url(:subdomain => options.try(:subdomain))
elsesuperendend
I think I would personally prefer to use articles_url with :subdomain option.
Joel,
I'm not sure if you are still looking for the answer, but as I just went through this episode and I am going to use a similar functionality with subdomains, as you need, I guess I know the answer for your question.
First of all, you can not expect to have in return of
_path
helper methods anything with the host. Instead use the_url
helper methods. That will lead you into the 2nd point.Based on the
root_url(:subdomain => @blog.name)
used in the episode and thanks to the overriddenurl_for
helper you can use thesubdomain
key in the options of any_url
helper methods. Here we go:I think you could also override
blogs_articles_url
helper method to be consistent with using nested resources way of creating urls. The below code is just an idea and should be re-factored to use all functionality ofblogs_articles_url
helper method, but for simplicity I put the below.I think I would personally prefer to use
articles_url
with:subdomain
option.Hope that helps.