Friday, March 28, 2008

Named Routes: url vs path

So I spent a good 30 minutes trying to figure out why my links were missing the host part of the URL.

What I was trying to do was send emails using ActionMailer and generating urls inside the ActionMailer instead of the ActionController. The documentation says that you can use url_for and named routes if you do what it says.

Well, for a while there, I was completely stumped as to why my named routes were missing the host part, until I realized I was using the path method for named routes instead of the url method:

users_path #/users
users_url #http://www.mysite.com/users

The difference is obvious. However, if you're used to using path instead of url, you may be stumped as well. Hopefully, you guys won't have to go through the trouble I did ;)


W

No comments: