Hello, So I have a web site with companies and products. I use REST and make companies a resource and products a resource (and a ''sub-resource'' of company). But only for viewing, no new, no create, no destroy, no update. Now I want to offer an admin interface that would be essentially the same but with an URL prefix of /my/ to the URL, same models, but that are viewed differently. Only the owned companies and products are shown (being logged in is a requirement for everything in /my/), the interface would be different, and it would allow create, destroy, update, etc. What is the RESTful way to do it? Thank you. -- J. Pablo Fernández <pupeno-GAtDADarczzQT0dZR+AlfA@public.gmane.org> http://pupeno.com
J. Pablo Fernández wrote:> Hello, > > So I have a web site with companies and products. I use REST and make > companies a resource and products a resource (and a ''sub-resource'' of > company). But only for viewing, no new, no create, no destroy, no > update. Now > I want to offer an admin interface that would be essentially the same > but > with an URL prefix of /my/ to the URL, same models, but that are viewed > differently. Only the owned companies and products are shown (being > logged in > is a requirement for everything in /my/), the interface would be > different, > and it would allow create, destroy, update, etc. What is the RESTful way > to > do it? > > Thank you.Rails 2.0 has namespaced routes that will create an additional controller in a subfolder named after the namespace, ex: ./script/generate controller my::companies will create a companies controller in the "my" folder, or so I have read -- Posted via http://www.ruby-forum.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?hl=en -~----------~----~----~----~------~----~------~--~---
Would you know any online resources or online tutorails that teach how to do this? Elle On Dec 15, 1:41 pm, Chris Olsen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> J. Pablo Fernández wrote: > > Hello, > > > So I have a web site with companies and products. I use REST and make > > companies a resource and products a resource (and a ''sub-resource'' of > > company). But only for viewing, no new, no create, no destroy, no > > update. Now > > I want to offer an admin interface that would be essentially the same > > but > > with an URL prefix of /my/ to the URL, same models, but that are viewed > > differently. Only the owned companies and products are shown (being > > logged in > > is a requirement for everything in /my/), the interface would be > > different, > > and it would allow create, destroy, update, etc. What is the RESTful way > > to > > do it? > > > Thank you. > > Rails 2.0 has namespaced routes that will create an additional > controller in a subfolder named after the namespace, ex: > ./script/generate controller my::companies > > will create a companies controller in the "my" folder, or so I have read > -- > Posted viahttp://www.ruby-forum.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?hl=en -~----------~----~----~----~------~----~------~--~---
On Saturday 15 December 2007 02:41:14 Chris Olsen wrote:> J. Pablo Fernández wrote: > > Hello, > > > > So I have a web site with companies and products. I use REST and make > > companies a resource and products a resource (and a ''sub-resource'' of > > company). But only for viewing, no new, no create, no destroy, no > > update. Now > > I want to offer an admin interface that would be essentially the same > > but > > with an URL prefix of /my/ to the URL, same models, but that are viewed > > differently. Only the owned companies and products are shown (being > > logged in > > is a requirement for everything in /my/), the interface would be > > different, > > and it would allow create, destroy, update, etc. What is the RESTful way > > to > > do it? > > > > Thank you. > > Rails 2.0 has namespaced routes that will create an additional > controller in a subfolder named after the namespace, ex: > ./script/generate controller my::companies > > will create a companies controller in the "my" folder, or so I have readYes, I''ve used to use that method in Rails 1.2, but I''m not sure it''ll lead to proper RESTful resources now. -- J. Pablo Fernández <pupeno-GAtDADarczzQT0dZR+AlfA@public.gmane.org> http://pupeno.com
On Saturday 15 December 2007 07:18:03 elle wrote:> Would you know any online resources or online tutorails that teach how > to do this?What do you exactly mean by "this"? If you mean learn RESTful Rails, I''ve learnt with http://b-simple.de/download/restful_rails_en.pdf -- J. Pablo Fernández <pupeno-GAtDADarczzQT0dZR+AlfA@public.gmane.org> http://pupeno.com
DHH talked about this in the RailsConf keynote, which you can read about here:
http://casperfabricius.com/blog/wp-content/uploads/2007/09/keynote-dhh.txt
basically you add the following to your routes file:
map.namespace :admin do |admin|
admin.resources :orders, :member => { :resend => :post }
admin.resources :users, :collection => { :filter => :any }
end
#want to allow public access to certain methods for orders and users
map.resources :orders, :users
then you''ll have a admin/users_controller.rb and
admin/orders_controller.rb files, as well as the public
users_controller and orders_controller. Your restful paths will look
like the following:
admin/users
admin/users/new
admin/users/edit
admin/orders/
admin/orders/edit
etc
so you stick your index and show methods in your public
users_controller, and put the admin index, create, update, etc, new,
etc into the admin/users_controller.
Adam
On 12/15/07, J. Pablo Fernández
<pupeno-GAtDADarczzQT0dZR+AlfA@public.gmane.org>
wrote:> On Saturday 15 December 2007 07:18:03 elle wrote:
> > Would you know any online resources or online tutorails that teach how
> > to do this?
>
> What do you exactly mean by "this"? If you mean learn RESTful
Rails, I''ve
> learnt with http://b-simple.de/download/restful_rails_en.pdf
>
> --
> J. Pablo Fernández <pupeno-GAtDADarczzQT0dZR+AlfA@public.gmane.org>
http://pupeno.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?hl=en
-~----------~----~----~----~------~----~------~--~---