Forum: Ruby on Rails Subdomain fu woes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cdc0bd35f31e570df39fb812c63ca0bc?d=identicon&s=25 andresmax@gmail.com (Guest)
on 2008-11-24 15:23
(Received via mailing list)
I'm using subdomain_fu successfully and generating subdomain routes
like this:

rotues.rb:
map.city_root '',:controller => 'cities', :action =>
'index', :conditions => { :subdomain => /.+/ }

using it in a view:
<%= link_to city.name, city_root_path(:subdomain => city.subdomain)%>

that works well, now I can't figure out how to generate a nested route
with subdomain,
i.e. miami.site.com/users/1

trying any combination of the form user_path(@user,:subdomain =>
city.subdomain) does nothing excepnt append a parameter at the end of
the url like this:

site.com/users/1?subdomain=miami

help is greatly appreciated guys!
Cdc0bd35f31e570df39fb812c63ca0bc?d=identicon&s=25 andresmax@gmail.com (Guest)
on 2008-11-24 16:04
(Received via mailing list)
Found the fix, it is a bug with the subdomain_fu plugin.

the solution may be found here

http://www.portallabs.com/blog/2008/10/22/fixing-s...
2505b282d57c29be797dc35b245adb4c?d=identicon&s=25 Philip Hallstrom (Guest)
on 2008-11-24 20:52
(Received via mailing list)
On Nov 24, 2008, at 6:22 AM, andresmax@gmail.com wrote:

>
> that works well, now I can't figure out how to generate a nested route
> with subdomain,
> i.e. miami.site.com/users/1
>
> trying any combination of the form user_path(@user,:subdomain =>
> city.subdomain) does nothing excepnt append a parameter at the end of
> the url like this:
>
> site.com/users/1?subdomain=miami

In addition to the fix you found, you may also want to check out this
patch.

http://rails.lighthouseapp.com/projects/8994/ticke...

I wrote that because of a recent site I built with 18 subdomains and
not wanting to write out all those links by hand.

In your case above you could define a to_params method on User to
return the hash (including the subdomain) and then just do
user_path(@user) and it will do the right thing.

Anyway, see the ticket for more info.

-philip
This topic is locked and can not be replied to.