Hello, I want to seperate my admin and public views but only use one controller. How to seperate layouts ist clear but how can I tell the controller to render the *.rhtml files in views/admin/ when logged in or render the *.rhtml files in views/public/ (for example). Thanks for any help! PS: using REST and CRUD in edge rails --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mike Garey
2006-Oct-28 16:00 UTC
Re: Seperate admin and public views using one controller REST CRUD
sorry I can''t provide much assistance for this question, but I thought
I''d also mention that I''m very interested in knowing how
others have
solved this.. It seems to be one of the sore points that I''ve come
across when switching my controllers to support rest.
Whereas before I used to have all the admin related tasks in my admin
controller, I''ve now tried to put them into my (for example), products
controller, but there''s times when I want the index for a regular user
to show one view and the index for the admin to show a more condensed
view that''s easier to navigate and edit entries.
So far what I''ve done to solve this is to use an
"admin_index" action
in my controller, as well as an admin_index.rhtml file in my views
directory, and then put the following in my routes file:
map.resources :products, :collection => { :admin_index => :get}
but I was wondering if anyone has a better method for accomplishing this..
in the restful rails peepcode screencast
(http://peepcode.com/articles/2006/10/08/restful-rails), they briefly
touch upon adding an administrative interface by using different
layouts, however, I don''t see how this works when you have more than a
single action that needs both a public and an administrative view
(plus, if you used a separate layout for each admin action, you''d
quickly find yourself with a whole mess of layouts)
the other alternative would be to keep the rest controllers the way
they are, but then still use an admin controller to provide the
administrative interface for the objects. But then you''ll end up
splitting your code between two controllers for a single object type,
which kinda goes against the notion of encapsulating all the methods
for a certain object in its own controller.
Anyone else have any thoughts on this topic? Would like to hear how
others are tackling this problem..
Mike
On 10/28/06, Jörg <jmkoch-Mmb7MZpHnFY@public.gmane.org>
wrote:>
> Hello,
>
> I want to seperate my admin and public views but only use one
> controller. How to seperate layouts ist clear but how can I tell the
> controller to render the *.rhtml files in views/admin/ when logged in or
> render the *.rhtml files in views/public/ (for example).
>
> Thanks for any help!
>
> PS: using REST and CRUD in edge rails
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Chris T
2006-Oct-28 17:48 UTC
Re: Seperate admin and public views using one controller REST CRUD
Mike Garey wrote:> sorry I can''t provide much assistance for this question, but I thought > I''d also mention that I''m very interested in knowing how others have > solved this.. It seems to be one of the sore points that I''ve come > across when switching my controllers to support rest. > > Whereas before I used to have all the admin related tasks in my admin > controller, I''ve now tried to put them into my (for example), products > controller, but there''s times when I want the index for a regular user > to show one view and the index for the admin to show a more condensed > view that''s easier to navigate and edit entries. > > So far what I''ve done to solve this is to use an "admin_index" action > in my controller, as well as an admin_index.rhtml file in my views > directory, and then put the following in my routes file: > > map.resources :products, :collection => { :admin_index => :get} > > but I was wondering if anyone has a better method for accomplishing this.. > > in the restful rails peepcode screencast > (http://peepcode.com/articles/2006/10/08/restful-rails), they briefly > touch upon adding an administrative interface by using different > layouts, however, I don''t see how this works when you have more than a > single action that needs both a public and an administrative view > (plus, if you used a separate layout for each admin action, you''d > quickly find yourself with a whole mess of layouts) > > the other alternative would be to keep the rest controllers the way > they are, but then still use an admin controller to provide the > administrative interface for the objects. But then you''ll end up > splitting your code between two controllers for a single object type, > which kinda goes against the notion of encapsulating all the methods > for a certain object in its own controller. > > Anyone else have any thoughts on this topic? Would like to hear how > others are tackling this problem.. > > Mike > > On 10/28/06, Jörg <jmkoch-Mmb7MZpHnFY@public.gmane.org> wrote: > >> Hello, >> >> I want to seperate my admin and public views but only use one >> controller. How to seperate layouts ist clear but how can I tell the >> controller to render the *.rhtml files in views/admin/ when logged in or >> render the *.rhtml files in views/public/ (for example). >> >> Thanks for any help! >> >> PS: using REST and CRUD in edge rails >> >> > > > > >Think there''s a number of ways of skinning this, but for me I kept the admin actions in the relevant REST controller (update & destroy, and for some controllers create too), but restricted access to them to admin users with a filter, then had an admin controller with a single index method, which acted as a dashboard, and a jumping off point for the other actions. That way the REST actions stay in the correct controllers, but the admin controller does just the only job it''s supposed to, which is to acts as an admin front page. I considered splitting the main front page index, so it acted as the admin index for admin users, normal for other users, but then decided that there were times that admins would want to see the front page other users saw without having to log out to do it. Just my $0.02. YMMV --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
lourens-Y3mZhnRYZ8+cKkwBFXVjUA@public.gmane.org
2006-Oct-30 02:23 UTC
Re: Seperate admin and public views using one controller REST CRUD
Chris T wrote:> Mike Garey wrote: > > sorry I can''t provide much assistance for this question, but I thought > > I''d also mention that I''m very interested in knowing how others have > > solved this.. It seems to be one of the sore points that I''ve come > > across when switching my controllers to support rest. > > > > Whereas before I used to have all the admin related tasks in my admin > > controller, I''ve now tried to put them into my (for example), products > > controller, but there''s times when I want the index for a regular user > > to show one view and the index for the admin to show a more condensed > > view that''s easier to navigate and edit entries. > > > > So far what I''ve done to solve this is to use an "admin_index" action > > in my controller, as well as an admin_index.rhtml file in my views > > directory, and then put the following in my routes file: > > > > map.resources :products, :collection => { :admin_index => :get} > > > > but I was wondering if anyone has a better method for accomplishing this.. > > > > in the restful rails peepcode screencast > > (http://peepcode.com/articles/2006/10/08/restful-rails), they briefly > > touch upon adding an administrative interface by using different > > layouts, however, I don''t see how this works when you have more than a > > single action that needs both a public and an administrative view > > (plus, if you used a separate layout for each admin action, you''d > > quickly find yourself with a whole mess of layouts) > > > > the other alternative would be to keep the rest controllers the way > > they are, but then still use an admin controller to provide the > > administrative interface for the objects. But then you''ll end up > > splitting your code between two controllers for a single object type, > > which kinda goes against the notion of encapsulating all the methods > > for a certain object in its own controller. > > > > Anyone else have any thoughts on this topic? Would like to hear how > > others are tackling this problem.. > > > > Mike > > > > On 10/28/06, Jörg <jmkoch-Mmb7MZpHnFY@public.gmane.org> wrote: > > > >> Hello, > >> > >> I want to seperate my admin and public views but only use one > >> controller. How to seperate layouts ist clear but how can I tell the > >> controller to render the *.rhtml files in views/admin/ when logged in or > >> render the *.rhtml files in views/public/ (for example). > >> > >> Thanks for any help! > >> > >> PS: using REST and CRUD in edge rails > >> > >> > > > > > > > > > > Think there''s a number of ways of skinning this, but for me I kept the > admin actions in the relevant REST controller (update & destroy, and for > some controllers create too), but restricted access to them to admin > users with a filter, then had an admin controller with a single index > method, which acted as a dashboard, and a jumping off point for the > other actions. > > That way the REST actions stay in the correct controllers, but the admin > controller does just the only job it''s supposed to, which is to acts as > an admin front page. I considered splitting the main front page index, > so it acted as the admin index for admin users, normal for other users, > but then decided that there were times that admins would want to see the > front page other users saw without having to log out to do it. > > Just my $0.02. YMMVHi, Have a look at the route below ... map.resources :coupons, :path_prefix => '':locale/admin'', :controller => ''admin/coupons'', :name_prefix => ''admin_'', :collection => { :sort => :post }, :member => { :status => :put } which yields example named routes: admin_coupons_url(), admin_sort_coupons_url(), admin_new_coupon_url() etc. You may also do the following, in coexistence with the above: map.resources :coupons, which yields non-namespaced equivalent, only difference being the admin_* prefix to named routes is dropped. I''ll do a short writeup on my blog about this soon, as plenty folks is affected in the migration to more RESTful codebases. Lourens Naude http://blog.methodmissing.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mike Garey
2006-Oct-30 18:24 UTC
Re: Seperate admin and public views using one controller REST CRUD
So does that mean you have two controllers, a coupons_controller for
the public site and an admin/coupons_controller for the admin actions?
What I was hoping for was that by using name_prefix =>
''admin_'', I
would get administrative actions of my crud methods, such as
"admin_index", "admin_create", etc.. But name_prefix
doesn''t seem to
do that..
Looks like I''ll have to just stick with using:
map.resources :products, :collection => { :admin_index => :get}
Mike
On 10/29/06, lourens-Y3mZhnRYZ8+cKkwBFXVjUA@public.gmane.org
<lourens-+kpahrjL8DnM9gW82pYGhQ@public.gmane.org>
wrote:>
>
> Chris T wrote:
> > Mike Garey wrote:
> > > sorry I can''t provide much assistance for this question,
but I thought
> > > I''d also mention that I''m very interested in
knowing how others have
> > > solved this.. It seems to be one of the sore points that
I''ve come
> > > across when switching my controllers to support rest.
> > >
> > > Whereas before I used to have all the admin related tasks in my
admin
> > > controller, I''ve now tried to put them into my (for
example), products
> > > controller, but there''s times when I want the index for
a regular user
> > > to show one view and the index for the admin to show a more
condensed
> > > view that''s easier to navigate and edit entries.
> > >
> > > So far what I''ve done to solve this is to use an
"admin_index" action
> > > in my controller, as well as an admin_index.rhtml file in my
views
> > > directory, and then put the following in my routes file:
> > >
> > > map.resources :products, :collection => { :admin_index =>
:get}
> > >
> > > but I was wondering if anyone has a better method for
accomplishing this..
> > >
> > > in the restful rails peepcode screencast
> > > (http://peepcode.com/articles/2006/10/08/restful-rails), they
briefly
> > > touch upon adding an administrative interface by using different
> > > layouts, however, I don''t see how this works when you
have more than a
> > > single action that needs both a public and an administrative view
> > > (plus, if you used a separate layout for each admin action,
you''d
> > > quickly find yourself with a whole mess of layouts)
> > >
> > > the other alternative would be to keep the rest controllers the
way
> > > they are, but then still use an admin controller to provide the
> > > administrative interface for the objects. But then
you''ll end up
> > > splitting your code between two controllers for a single object
type,
> > > which kinda goes against the notion of encapsulating all the
methods
> > > for a certain object in its own controller.
> > >
> > > Anyone else have any thoughts on this topic? Would like to hear
how
> > > others are tackling this problem..
> > >
> > > Mike
> > >
> > > On 10/28/06, Jörg <jmkoch-Mmb7MZpHnFY@public.gmane.org>
wrote:
> > >
> > >> Hello,
> > >>
> > >> I want to seperate my admin and public views but only use one
> > >> controller. How to seperate layouts ist clear but how can I
tell the
> > >> controller to render the *.rhtml files in views/admin/ when
logged in or
> > >> render the *.rhtml files in views/public/ (for example).
> > >>
> > >> Thanks for any help!
> > >>
> > >> PS: using REST and CRUD in edge rails
> > >>
> > >>
> > >
> > > >
> > >
> > >
> > Think there''s a number of ways of skinning this, but for me I
kept the
> > admin actions in the relevant REST controller (update & destroy,
and for
> > some controllers create too), but restricted access to them to admin
> > users with a filter, then had an admin controller with a single index
> > method, which acted as a dashboard, and a jumping off point for the
> > other actions.
> >
> > That way the REST actions stay in the correct controllers, but the
admin
> > controller does just the only job it''s supposed to, which is
to acts as
> > an admin front page. I considered splitting the main front page index,
> > so it acted as the admin index for admin users, normal for other
users,
> > but then decided that there were times that admins would want to see
the
> > front page other users saw without having to log out to do it.
> >
> > Just my $0.02. YMMV
>
> Hi,
>
> Have a look at the route below ...
>
> map.resources :coupons, :path_prefix =>
'':locale/admin'', :controller
> => ''admin/coupons'', :name_prefix =>
''admin_'', :collection => { :sort =>
> :post }, :member => { :status => :put }
>
> which yields example named routes: admin_coupons_url(),
> admin_sort_coupons_url(), admin_new_coupon_url() etc.
>
> You may also do the following, in coexistence with the above:
> map.resources :coupons, which yields non-namespaced equivalent, only
> difference being the admin_* prefix to named routes is dropped.
>
> I''ll do a short writeup on my blog about this soon, as plenty
folks is
> affected in the migration to more RESTful codebases.
>
> Lourens Naude
> http://blog.methodmissing.com
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
ljredpath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Oct-30 20:39 UTC
Re: Seperate admin and public views using one controller REST CRUD
name_prefix gives a prefix to the generated named routes. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---