i have a newbie question. been playing around with RoR for a while now, but finally building an application for public usage. my question concerns how to create an admin section and a public section of the website/application. for instance, i want an admin section which lets the owners of the site log and make changes. i''m wondering do i need multiple controllers with authentication turned on (i''m using a standard example, which uses a before_filter on controllers that require login) for admin and separate controllers to be used by the public pages? i''m not sure if i''m explaining this correctly. here''s a list of things i''m trying to accomplish: Models: food categories events Admin Controllers/pages: food categories events public pages (separate controllers and views needed?: food (sorted by categories) events and if i do need separate controllers and views, do i link them to the shared models using custom Routes? sorry if this is confusing. thanks joe --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The answer is: you can do anything you want :) But new in Rails 2.0 is Namespaces in Routes, there are a few primers on what there are and how to use them, I found this on Google, should get you started: http://railstips.org/2007/4/28/namespaces-added-to-routes The other option is to use in-place editing, where the actual option to click on a field and edit it only exists if you''re an admin/authorized. It actually cleans up controller code a bit. That''s how I solved this problem. On Feb 5, 9:00 pm, CarbonJoeTunis <joe.tu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i have a newbie question. been playing around with RoR for a while > now, but finally building an application for public usage. my question > concerns how to create an admin section and a public section of the > website/application. for instance, i want an admin section which lets > the owners of the site log and make changes. i''m wondering do i need > multiple controllers with authentication turned on (i''m using a > standard example, which uses a before_filter on controllers that > require login) for admin and separate controllers to be used by the > public pages? i''m not sure if i''m explaining this correctly. here''s a > list of things i''m trying to accomplish: > > Models: > food > categories > events > > Admin Controllers/pages: > food > categories > events > > public pages (separate controllers and views needed?: > food (sorted by categories) > events > > and if i do need separate controllers and views, do i link them to the > shared models using custom Routes? > > sorry if this is confusing. thanks > > joe--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thanks for the info. i''ll check out the namespaces link. On Feb 5, 9:15 pm, rick <rick.richard...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The answer is: you can do anything you want :) > > But new in Rails 2.0 is Namespaces in Routes, there are a few primers > on what there are and how to use them, > I found this on Google, should get you started:http://railstips.org/2007/4/28/namespaces-added-to-routes > > The other option is to use in-place editing, where the actual option > to click on a field and edit it only exists > if you''re an admin/authorized. It actually cleans up controller code a > bit. That''s how I solved this problem. > > On Feb 5, 9:00 pm, CarbonJoeTunis <joe.tu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > i have a newbie question. been playing around with RoR for a while > > now, but finally building an application for public usage. my question > > concerns how to create an admin section and a public section of the > > website/application. for instance, i want an admin section which lets > > the owners of the site log and make changes. i''m wondering do i need > > multiple controllers with authentication turned on (i''m using a > > standard example, which uses a before_filter on controllers that > > require login) for admin and separate controllers to be used by the > > public pages? i''m not sure if i''m explaining this correctly. here''s a > > list of things i''m trying to accomplish: > > > Models: > > food > > categories > > events > > > Admin Controllers/pages: > > food > > categories > > events > > > public pages (separate controllers and views needed?: > > food (sorted by categories) > > events > > > and if i do need separate controllers and views, do i link them to the > > shared models using custom Routes? > > > sorry if this is confusing. thanks > > > joe--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
The third option is to use different layouts and templates based on if they are logged in. This lets you completely customize the look for admins while maintaining basically the same controllers. I haven''t made up my mind on which way is best. On Feb 5, 6:15 pm, rick <rick.richard...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The answer is: you can do anything you want :) > > But new in Rails 2.0 is Namespaces in Routes, there are a few primers > on what there are and how to use them, > I found this on Google, should get you started:http://railstips.org/2007/4/28/namespaces-added-to-routes > > The other option is to use in-place editing, where the actual option > to click on a field and edit it only exists > if you''re an admin/authorized. It actually cleans up controller code a > bit. That''s how I solved this problem. > > On Feb 5, 9:00 pm, CarbonJoeTunis <joe.tu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > i have a newbie question. been playing around with RoR for a while > > now, but finally building an application for public usage. my question > > concerns how to create an admin section and a public section of the > > website/application. for instance, i want an admin section which lets > > the owners of the site log and make changes. i''m wondering do i need > > multiple controllers with authentication turned on (i''m using a > > standard example, which uses a before_filter on controllers that > > require login) for admin and separate controllers to be used by the > > public pages? i''m not sure if i''m explaining this correctly. here''s a > > list of things i''m trying to accomplish: > > > Models: > > food > > categories > > events > > > Admin Controllers/pages: > > food > > categories > > events > > > public pages (separate controllers and views needed?: > > food (sorted by categories) > > events > > > and if i do need separate controllers and views, do i link them to the > > shared models using custom Routes? > > > sorry if this is confusing. thanks > > > joe--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
that''s probably more what i was thinking. so where do you do the check for login? in the controller for each model/view? right now, i''m doing a before_filter to call my authenticate action. i''m thinking i have to move that somewhere else? how would i go about that? thanks joe On Feb 6, 12:46 am, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> The third option is to use different layouts and templates based on if > they are logged in. This lets you completely customize the look for > admins while maintaining basically the same controllers. > > I haven''t made up my mind on which way is best. > > On Feb 5, 6:15 pm, rick <rick.richard...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > The answer is: you can do anything you want :) > > > But new in Rails 2.0 is Namespaces in Routes, there are a few primers > > on what there are and how to use them, > > I found this on Google, should get you started:http://railstips.org/2007/4/28/namespaces-added-to-routes > > > The other option is to use in-place editing, where the actual option > > to click on a field and edit it only exists > > if you''re an admin/authorized. It actually cleans up controller code a > > bit. That''s how I solved this problem. > > > On Feb 5, 9:00 pm, CarbonJoeTunis <joe.tu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > i have a newbie question. been playing around with RoR for a while > > > now, but finally building an application for public usage. my question > > > concerns how to create an admin section and a public section of the > > > website/application. for instance, i want an admin section which lets > > > the owners of the site log and make changes. i''m wondering do i need > > > multiple controllers with authentication turned on (i''m using a > > > standard example, which uses a before_filter on controllers that > > > require login) for admin and separate controllers to be used by the > > > public pages? i''m not sure if i''m explaining this correctly. here''s a > > > list of things i''m trying to accomplish: > > > > Models: > > > food > > > categories > > > events > > > > Admin Controllers/pages: > > > food > > > categories > > > events > > > > public pages (separate controllers and views needed?: > > > food (sorted by categories) > > > events > > > > and if i do need separate controllers and views, do i link them to the > > > shared models using custom Routes? > > > > sorry if this is confusing. thanks > > > > joe--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
in the respond_to block. I saw it in the Peepcode video on Restful development. Here is some code that should give you some ideas: format.html do render(:layout => "admin") if logged_in? end I haven''t tried this yet but I think you can also do something like this: format.html do render(:layout => "admin", :template => "admin_index") if logged_in? end On Feb 5, 11:16 pm, CarbonJoeTunis <joe.tu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> that''s probably more what i was thinking. so where do you do the check > for login? in the controller for each model/view? right now, i''m doing > a before_filter to call my authenticate action. i''m thinking i have to > move that somewhere else? how would i go about that? thanks > > joe > > On Feb 6, 12:46 am, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote: > > > The third option is to use different layouts and templates based on if > > they are logged in. This lets you completely customize the look for > > admins while maintaining basically the same controllers. > > > I haven''t made up my mind on which way is best. > > > On Feb 5, 6:15 pm, rick <rick.richard...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > The answer is: you can do anything you want :) > > > > But new in Rails 2.0 is Namespaces in Routes, there are a few primers > > > on what there are and how to use them, > > > I found this on Google, should get you started:http://railstips.org/2007/4/28/namespaces-added-to-routes > > > > The other option is to use in-place editing, where the actual option > > > to click on a field and edit it only exists > > > if you''re an admin/authorized. It actually cleans up controller code a > > > bit. That''s how I solved this problem. > > > > On Feb 5, 9:00 pm, CarbonJoeTunis <joe.tu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > i have a newbie question. been playing around with RoR for a while > > > > now, but finally building an application for public usage. my question > > > > concerns how to create an admin section and a public section of the > > > > website/application. for instance, i want an admin section which lets > > > > the owners of the site log and make changes. i''m wondering do i need > > > > multiple controllers with authentication turned on (i''m using a > > > > standard example, which uses a before_filter on controllers that > > > > require login) for admin and separate controllers to be used by the > > > > public pages? i''m not sure if i''m explaining this correctly. here''s a > > > > list of things i''m trying to accomplish: > > > > > Models: > > > > food > > > > categories > > > > events > > > > > Admin Controllers/pages: > > > > food > > > > categories > > > > events > > > > > public pages (separate controllers and views needed?: > > > > food (sorted by categories) > > > > events > > > > > and if i do need separate controllers and views, do i link them to the > > > > shared models using custom Routes? > > > > > sorry if this is confusing. thanks > > > > > joe--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Oh yea, you''d also probably want to restrict access to some of the actions using: before_filter :login_required, :except => [:index, :show, :home] These are all cut/paste from the peepcode code. I highly recommend them. For $9, its the best training on rails available... either than RailsCasts.com On Feb 5, 11:16 pm, CarbonJoeTunis <joe.tu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> that''s probably more what i was thinking. so where do you do the check > for login? in the controller for each model/view? right now, i''m doing > a before_filter to call my authenticate action. i''m thinking i have to > move that somewhere else? how would i go about that? thanks > > joe > > On Feb 6, 12:46 am, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote: > > > The third option is to use different layouts and templates based on if > > they are logged in. This lets you completely customize the look for > > admins while maintaining basically the same controllers. > > > I haven''t made up my mind on which way is best. > > > On Feb 5, 6:15 pm, rick <rick.richard...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > The answer is: you can do anything you want :) > > > > But new in Rails 2.0 is Namespaces in Routes, there are a few primers > > > on what there are and how to use them, > > > I found this on Google, should get you started:http://railstips.org/2007/4/28/namespaces-added-to-routes > > > > The other option is to use in-place editing, where the actual option > > > to click on a field and edit it only exists > > > if you''re an admin/authorized. It actually cleans up controller code a > > > bit. That''s how I solved this problem. > > > > On Feb 5, 9:00 pm, CarbonJoeTunis <joe.tu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > i have a newbie question. been playing around with RoR for a while > > > > now, but finally building an application for public usage. my question > > > > concerns how to create an admin section and a public section of the > > > > website/application. for instance, i want an admin section which lets > > > > the owners of the site log and make changes. i''m wondering do i need > > > > multiple controllers with authentication turned on (i''m using a > > > > standard example, which uses a before_filter on controllers that > > > > require login) for admin and separate controllers to be used by the > > > > public pages? i''m not sure if i''m explaining this correctly. here''s a > > > > list of things i''m trying to accomplish: > > > > > Models: > > > > food > > > > categories > > > > events > > > > > Admin Controllers/pages: > > > > food > > > > categories > > > > events > > > > > public pages (separate controllers and views needed?: > > > > food (sorted by categories) > > > > events > > > > > and if i do need separate controllers and views, do i link them to the > > > > shared models using custom Routes? > > > > > sorry if this is confusing. thanks > > > > > joe--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
yeah, definitely been digging PeepCode thus far. so i figured out what i really wanted to do. i''ve been stuck in the 1 Model : 1 Controller : 1 View mindset. when today, i thought, why not create a different controller and view pair for each public website section i want. is this frowned upon or a perk of the MVC pattern? thanks to all for the help. joe On Feb 6, 2:52 am, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> Oh yea, you''d also probably want to restrict access to some of the > actions using: > > before_filter :login_required, :except => [:index, :show, :home] > > These are all cut/paste from the peepcode code. I highly recommend > them. For $9, its the best training on rails available... either than > RailsCasts.com > > On Feb 5, 11:16 pm, CarbonJoeTunis <joe.tu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > that''s probably more what i was thinking. so where do you do the check > > for login? in the controller for each model/view? right now, i''m doing > > a before_filter to call my authenticate action. i''m thinking i have to > > move that somewhere else? how would i go about that? thanks > > > joe > > > On Feb 6, 12:46 am, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote: > > > > The third option is to use different layouts and templates based on if > > > they are logged in. This lets you completely customize the look for > > > admins while maintaining basically the same controllers. > > > > I haven''t made up my mind on which way is best. > > > > On Feb 5, 6:15 pm, rick <rick.richard...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > The answer is: you can do anything you want :) > > > > > But new in Rails 2.0 is Namespaces in Routes, there are a few primers > > > > on what there are and how to use them, > > > > I found this on Google, should get you started:http://railstips.org/2007/4/28/namespaces-added-to-routes > > > > > The other option is to use in-place editing, where the actual option > > > > to click on a field and edit it only exists > > > > if you''re an admin/authorized. It actually cleans up controller code a > > > > bit. That''s how I solved this problem. > > > > > On Feb 5, 9:00 pm, CarbonJoeTunis <joe.tu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > i have a newbie question. been playing around with RoR for a while > > > > > now, but finally building an application for public usage. my question > > > > > concerns how to create an admin section and a public section of the > > > > > website/application. for instance, i want an admin section which lets > > > > > the owners of the site log and make changes. i''m wondering do i need > > > > > multiple controllers with authentication turned on (i''m using a > > > > > standard example, which uses a before_filter on controllers that > > > > > require login) for admin and separate controllers to be used by the > > > > > public pages? i''m not sure if i''m explaining this correctly. here''s a > > > > > list of things i''m trying to accomplish: > > > > > > Models: > > > > > food > > > > > categories > > > > > events > > > > > > Admin Controllers/pages: > > > > > food > > > > > categories > > > > > events > > > > > > public pages (separate controllers and views needed?: > > > > > food (sorted by categories) > > > > > events > > > > > > and if i do need separate controllers and views, do i link them to the > > > > > shared models using custom Routes? > > > > > > sorry if this is confusing. thanks > > > > > > joe--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''d highly recommend using namespaces so you can have a separate controller/views. For the layout (I use just a single admin layout), create a switch method in your application controller: layout :set_layout def set_layout params[:controller] =~ /^admin/ ? ''admin'' : ''public'' end Hope this helps, Matt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---