# Object creation when the controller is a subclass of AdminController

**URL:** <https://www.ruby-forum.com/t/object-creation-when-the-controller-is-a-subclass-of-admincontroller/132671>\
**Category:** Rails\
**Created:** [March 23, 2008, 1:22am UTC](https://www.ruby-forum.com/t/object-creation-when-the-controller-is-a-subclass-of-admincontroller/132671 "2008-03-23T01:22:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/48db29/32.png) [@ntk](https://www.ruby-forum.com/u/ntk)\
**Post date:** [March 23, 2008, 1:22am UTC](https://www.ruby-forum.com/t/object-creation-when-the-controller-is-a-subclass-of-admincontroller/132671/1 "2008-03-23T01:22:37Z")

</div>

I’ve finally determined that the best way to handle administration of  
a model that displays publicly but is administered privately is  
through subclassing but I’ve run in to pathing issues (I think) when  
trying to create an instance of my model.

Let’s say I have a Book, and BookController is a sublcass of  
AdminController so that I can create and delete Books via an Admin  
section. Everything is going smoothly, I’ve set up my resources so  
that my controller falls under /admin but it seems to me like my “new  
Book” form generates it’s action path for books, not Admin Books even  
though it’s within the views/admin/book folder.

My form is very simple…

form\_for @book do |f|…, whose action should be admin/book/create (or  
new?, it’s RESTful).

With this, loading book/new tells me “books\_path not found”. Does my  
application not recognize that the current view is under the admin/  
folder? Do I have to specify the url?

---

<div class="post-metadata">

**Author:** ![ntk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/48db29/32.png) [@ntk](https://www.ruby-forum.com/u/ntk)\
**Post date:** [March 23, 2008, 3:10am UTC](https://www.ruby-forum.com/t/object-creation-when-the-controller-is-a-subclass-of-admincontroller/132671/2 "2008-03-23T03:10:37Z")

</div>

Only took me 2 hours but I’ve answered my own question. I pluralized  
my controller; went from BookController to BooksController. I also  
changed my form\_for call to "form\_for [:admin, @book], bam! Works  
like a charm. I was trying to avoid specifying a path and I was able  
to do so this way.

Dave K.
