RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: DoppioJP
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:
root_url(:subdomain => @blog.name)
articles_url(:subdomain => @blog.try(:subdomain))
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.
def blogs_articles_url(options = nil)
articles_url(:subdomain => options.try(:subdomain))
I think I would personally prefer to use articles_url with :subdomain option.
Hope that helps.