Forum: Ruby on Rails REST versus RPC in Rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Lza (Guest)
on 2007-05-29 02:42
(Received via mailing list)
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.
Ben J. (Guest)
on 2007-05-29 12:22
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.
(Guest)
on 2007-05-30 17:57
(Received via mailing list)
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
This topic is locked and can not be replied to.