David K.
2008-Mar-23 00:21 UTC
Object creation when the controller is a subclass of AdminController
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? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David K.
2008-Mar-23 02:09 UTC
Re: Object creation when the controller is a subclass of AdminController
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. On Mar 22, 8:21 pm, "David K." <davidk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Possibly Parallel Threads
- Inheriting from AdminController intstead from ApplicationController
- help needed regaring Acts As Taggable On Steroids
- NoMethodError in Book#show_subjects
- How to transfer a javascript value into a symbol used in Ruby on Rails
- uninitialized constant BooksController::Books