Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails url helpers in subdomains - remove the subdomain

A user on my site can have a subdomain. So for example, their page url is

name.example.com 

Logged in users are able to view more user information so on the user's show page, I have a link that is generated with the following code:

user_url(@user, :subdomain => false)

This link should generate the following url (where @user has an ID of 19)

example.com/users/19

When I hover over the link, all looks good (i.e., in the bottom of the browser window, both Safari and FF show the link correctly.)

Problem is when I click the link, the site raises a 404 and the url is:

example.com/users/19

Anyone know what happened to the slash between com and users and how do I get it back?

BTW, Rails 3.2 and everything works in development. This issue only arises in production.

like image 757
Angelo Chrysoulakis Avatar asked Mar 25 '13 19:03

Angelo Chrysoulakis


1 Answers

First suggestion was using path helper instead of user helper, but editing that as I don't think that helps.

Have you tried root_url(:host => request.domain) to lose the subdomain, instead of your approach? I got that from here: https://github.com/rails/rails/issues/2025

like image 85
Richard Jordan Avatar answered Sep 21 '22 09:09

Richard Jordan