# Access name\_prefix from ApplicationController?

**URL:** <https://www.ruby-forum.com/t/access-name-prefix-from-applicationcontroller/107583>\
**Category:** Rails\
**Created:** [June 23, 2007, 6:17pm UTC](https://www.ruby-forum.com/t/access-name-prefix-from-applicationcontroller/107583 "2007-06-23T18:17:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phraktyl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@phraktyl](https://www.ruby-forum.com/u/phraktyl)\
**Post date:** [June 23, 2007, 6:17pm UTC](https://www.ruby-forum.com/t/access-name-prefix-from-applicationcontroller/107583/1 "2007-06-23T18:17:20Z")

</div>

Hi all,

Long time lurker, first time poster.

I’m trying to use REST::RestController for my CRUD operations in an  
app, which works great unless I’m using a name\_prefix in routes.db. In  
this case, it tries to send me to users\_path instead of  
admin\_users\_path, which throws an exception.

Is there a way I can access the name\_prefix from within  
REST::RestController, so I can modify the resource\_path and  
resources\_path methods to use the name\_prefix if it’s set?

Thanks

---

<div class="post-metadata">

**Author:** ![phraktyl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/c0e974/32.png) [@phraktyl](https://www.ruby-forum.com/u/phraktyl)\
**Post date:** [June 24, 2007, 6:41pm UTC](https://www.ruby-forum.com/t/access-name-prefix-from-applicationcontroller/107583/2 "2007-06-24T18:41:26Z")

</div>

> REST::RestController, so I can modify the resource\_path and  
> resources\_path methods to use the name\_prefix if it’s set?

As I can’t figure out how to access the name\_prefix, the other way that  
seems possible is to create an Admin::REST::RestController \<  
REST::RestController, which overloads the resource\_path and  
resources\_path methods and hardcodes the ‘\_admin’ string.

So for the admin controllers I would use Admin::REST::RestController,  
and for the others I would use REST::RestController. This would still be  
DRY in my thinking because the only mmethods in the Admin version would  
be the two that return the path.

I don’t like the hardcoded ‘\_admin’, but I can’t see another way to do  
it.

Thanks,  
Wyatt
