For some reason I get a NameError whenever I try to use path but url works great. Is there any reason to believe that path is deprecated or replaced with something else? Or is there something else we need to set somewhere for this to work right?
With the routes, my named route only works if I put it right at the top, otherwise it says "undefined method"; I need to put something above it otherwise it wrecks the program, but the named route doesn't work with anything above it (although nothing is "overwriting" it); how do I fix this?
I know this is years too late. But I was wondering if you could clear up Gabriel Mansour and Mo Rashed's questions (comments 10 and 11 respectively) It's just that those are exactly the two things I was scratching my head over.
Great episode as always!
If I'm not mistaken, you've used this kind of a named route ('resources') behind the scenes in episode 21 as well....(REST).
Gr,
- J.
Cool!
Congratulations,
this screencast is fabulous.
@Jermaine, yep, I've been using this technique all over the place in previous episodes. Thought it was about time I explained it. :)
For some reason I get a NameError whenever I try to use path but url works great. Is there any reason to believe that path is deprecated or replaced with something else? Or is there something else we need to set somewhere for this to work right?
@Gary, what version of Rails are you using? It may require 1.2 but I"m not sure.
Great stuff!
Btw, Errtheblog.com has a helpful rake task to print out all of your named routes, here:
http://require.errtheblog.com/projects/browser/dugg/lib/tasks/err.rake?format=raw
So whenever I need to know what named routes are available for a resource, I just do:
rake routes | grep post
That's extremely useful, thanks Geoff!
For those not sure how to install it, add the .rake file to your lib/tasks directory.
I finally understood what was the problem with path not working. I had updated the gems but hadn't updated the version number in environment.rb.
Once I updated it everything worked fine.
Hi Ryan,
One thing I noticed was that when
/page/1;edit
/page/edit/1
Sup Ryan,
When you did:
map.task_archive 'tasks/:year/:month', :controller => 'tasks', :action => 'archive'
Doesnt this conflict with the standard routing:
tasks/show/2
thnxs
With the routes, my named route only works if I put it right at the top, otherwise it says "undefined method"; I need to put something above it otherwise it wrecks the program, but the named route doesn't work with anything above it (although nothing is "overwriting" it); how do I fix this?
Nice work btw,
Thanks In Advance,
Joe
Hello Ryan,
I know this is years too late. But I was wondering if you could clear up Gabriel Mansour and Mo Rashed's questions (comments 10 and 11 respectively) It's just that those are exactly the two things I was scratching my head over.
Thanks,
Matt
This episode has been updated for Rails 5 as a blog post. Named Routes in Rails 5