# Changing the model\_path

**URL:** <https://www.ruby-forum.com/t/changing-the-model-path/192199>\
**Category:** Rails\
**Created:** [July 26, 2010, 8:31am UTC](https://www.ruby-forum.com/t/changing-the-model-path/192199 "2010-07-26T08:31:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [July 26, 2010, 8:31am UTC](https://www.ruby-forum.com/t/changing-the-model-path/192199/1 "2010-07-26T08:31:00Z")

</div>

Hi,

I’m new to RoR, but currently need to make some changes to my site to  
implement permalinks.  
Whenever I do a link, I use: category\_path(category) and then the  
to\_param permalinks it. The previous piece of code would link you to /  
categories/CategoryPermalink; the trouble is I don’t want it to be /  
categories, I just want it to be /PERMALINK.  
Then I’m getting into even more trouble, as each category has\_many  
tutorials, I have to do the same with this. At the moment  
tutorial\_path(tutorial) makes it go to /tutorial/TutorialPermalink,  
however I want it to go to /CategoryPermalink/TutorialPermalink.

Is there any way of doing this (at the moment I’m playing around with  
routes.rb, and then changing the action, and controller in the link; I  
don’t really know what I’m doing, but this seems to alter the URL  
sometimes).

After I figure this out I have to then redirect all of the other URLs  
(/categories/id, /tutorials/id, /CategoryPermalink/tutorialid, /  
categories/id/tutorials/id and any other URLs that have the same type  
of ideas) to the right URLs (I don’t have a clue how to do this  
either, but I guess I’ll leave that for another thread).

Please Help,

Thanks In Advance,

Joe

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [July 26, 2010, 9:49pm UTC](https://www.ruby-forum.com/t/changing-the-model-path/192199/2 "2010-07-26T21:49:34Z")

</div>

Bump?!

Please Help,

Thanks In Advance,

Joe

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [July 27, 2010, 8:55am UTC](https://www.ruby-forum.com/t/changing-the-model-path/192199/3 "2010-07-27T08:55:38Z")

</div>

Can anyone help with this?

I really need help,

Please Help,

Thanks In Advance,

Joe

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [July 27, 2010, 10:51pm UTC](https://www.ruby-forum.com/t/changing-the-model-path/192199/4 "2010-07-27T22:51:40Z")

</div>

Aha, I think I’ve finally figured it out with named routes!  
However my named route only works when its on the top line, and I need  
to make a static map.connect above it or the web app wont work; why  
does it make me put it at the top (there is nothing overwriting it or  
anything below). When it’s not at the top it says this: undefined  
method `catpmlnk’ (which is the named route name)…

Please help (I’m so close to solving my problems!),

Thanks In Advance,

Joe

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [July 27, 2010, 6:34pm UTC](https://www.ruby-forum.com/t/changing-the-model-path/192199/5 "2010-07-27T18:34:38Z")

</div>

Ok, I think I’ve made a tiny bit of progress. I’ve got the URLs I want  
to work using routes.rb

I now just need to application to link to the right place, Im trying  
to get it to go to “CATID/ID” but it links to “categories/ID?  
cat\_id=CATID”.

I’m giving it all of the correct parameters that my routes require,  
however it for some reason want to link to it as shown above.

Please Help,

Thanks In Advance,

Joe
