0

I'm trying to create some pages in HAML, which are partly working. The HTML that it produces is correct, apart from one thing. Where I have:

%ul#menu 
  %li 
    = link_to 'Home', root_url

I am expecting to get back:

<a href="/">Home</a>

Instead, it is producing:

<a href>Home</a>

Upon looking into it further, it seems that all of my named routes are simply returning a blank string and not the route they are meant to. This is happening on all of them not just root.

If I try changing it to a made-up name, something like 'test_path' then, as I expect, I get an error saying the method doesn't exist, so it's not a case of not being able to find it, it's simply not returning anything.

In the Rails console I am able to get the correct route so I know it's working, and rake routes gives me:

about        /about(.:format)                   welcome#about
contact      /contact(.:format)                 welcome#contact
faq          /faq(.:format)                     welcome#faq
plans        /plans(.:format)                   welcome#plans
root         /                                  welcome#index

Can anyone help as this is a pretty major issue and makes it pretty hard to keep developing if I can't generate links to anything

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
PaReeOhNos
  • 4,338
  • 3
  • 30
  • 41
  • That's not normal... And nothing you've posted would tell us why. Are you using any wierd gems or plugins that might interfere with routing? – Alex Wayne Apr 04 '13 at 23:47
  • maybe if you can put your project on github or any other services someone can have a look at it – pjam Apr 04 '13 at 23:47
  • 1
    Actually... What happens if you use `root_path` instead of `root_url`? – Alex Wayne Apr 04 '13 at 23:49
  • Exactly the same thing. _path or _url returns nothing. I can't think of any gems that would break it. It was originally working when I was using ERB but now It's not working with ERB again :( I've commented out the newest gems I've added before it stopped working and it's still not working. I can't really make a public repo as it's for another company so is private :( – PaReeOhNos Apr 04 '13 at 23:52

1 Answers1

0

OK, I figured out what it was.

The application I'm working on uses BaseCamp-style subdomains for an organisation.

Following Railscast #221 Subdomains in Rails 3 on implementing subdomains, I had created the url_for method as shown, however simply missed the super keyword so it was never generating the URL.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
PaReeOhNos
  • 4,338
  • 3
  • 30
  • 41