I have made a similar post to this one before, however I decided to repost it as a more general purpose question to elicit the views of the Rails community. I have been trying to design an application in Ruby on Rails using a REST style, however I am getting stuck on the issue of pages that need to display multiple resources, for instance a home page that has many different resource on that page, or a page that has both hotel rooms and advertisements. I posted a question like this before on the group and got an interesting reply as the first response (http:// groups.google.com/group/rubyonrails-talk/browse_thread/thread/ 8653e9f0047170df), saying in part that Rails doesn''t seem to have good support for this style of interaction at the moment, and this seems to be true as far as I can tell. So I have a number of questions, to see if I can get some general opinions: 1. Is it true that Rails does not support this type of interaction? 2. Does REST in general support this? 3. Does this mean that most general purpose websites can not be written according to a REST style? 4. Should Rails support this type of interaction if it doesn''t already? 5. In the case of Rails and nested resources, what happens when a parent has multiple children? How does one expose this in Rails? Thanks for your time. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Lza wrote:> > 1. Is it true that Rails does not support this type of interaction? > > 2. Does REST in general support this? > > 3. Does this mean that most general purpose websites can not be > written according to a REST style? > > 4. Should Rails support this type of interaction if it doesn''t > already? > > 5. In the case of Rails and nested resources, what happens when a > parent has multiple children? How does one expose this in Rails? > > > Thanks for your time.The purpose of REST development is to provide a way to access resources on another computer through many different mediums. Whether it be an html request, xml request, javascript request, etc. In a sense it is a smarter way to do web services in my opinion. The problem you are having is that you are trying to take a typical website / application and follow the REST style of development. This really complicates things because you have pages that contain multiple resources and unique functionality that is not cut and dry CRUD. In my opinion the REST style of development is more for an admin area, where you are performing CRUD actions. Rest is a good thing, just don''t get too literal with it, use it where it makes sense. To answer your last question, nested resources are set up in the routing. You can do: map.resources :categories do |categories| categories.resources :products end You can continue to nest as much as you like. To access this you simple use the following URL structure: /categories /categories/5 /categories/5/products /categories/5/products/6 Those are just example URLs, the numbers obviously represent IDs. I would suggest reading a quick REST tutorial. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
christophermatthieu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-May-30 13:56 UTC
Re: REST versus RPC in Rails
The Rails development philosophy is more of a guideline rather than a hard rule. You don''t need to develop in REST if it is not appropriate for your site. I have developed many non-REST Rails applications that mix unrelated models on the same page. If it''s what the customer wants - the customer gets :) Though not recommended, you can even make Active Record calls from your View rather than your Controller. Both Ruby and Rails are flexible enough to stray outside of the conventional to solve problems. I have more recently been toying with the idea that REST can be used more as client/server development where you could basically have two applications working together to solve a problem. The underlying RESTful application manages the data and web services while another non-RESTful application manages the presentation layer of your web application. It would be interesting to see if anyone has tried this approach. Cheers, Chris Matthieu http://www.Rubyology.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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---