Forum: Ruby on Rails Design Advice

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.
624b83b6eb01ed19fe7b397e4e198f00?d=identicon&s=25 Will Gant (Guest)
on 2007-06-27 15:48
(Received via mailing list)
Hello all,
I'm about to start working on a part of my application that interfaces
with an external system using HTTP (old school, not webservices).
Anyway, several of my controllers will need to access this
functionality, but there are some places where the functionality doesn't
fit perfectly with my design. I was thinking about putting most of the
interaction with the external site in its own controller and then
calling that from controllers in my application as needed. Of course,
such a controller wouldn't be associated with a model. I'm not sure what
effect this will have.

How would you handle it?


---------------------------------
Ready for the edge of your seat? Check out tonight's top picks on Yahoo!
TV.
15eb647956921a6bc9655c3513feb139?d=identicon&s=25 lanzm (Guest)
on 2007-06-27 16:10
(Received via mailing list)
I'd put it into a class under lib/ and not into a controller;
controllers shall be thin and glue the view and the model. it depends
how you "see" your external resource; you can look at it like a model.

a bit more important could be the fact that external access to the
resource will lock-up your users request and bind one of your mongrel
(or rails instances) to that request. you can use backgroundrb (http://
backgroundrb.rubyforge.org/) for such cases and communicate
asynchronously with your external system.
A0f6b57661bc57b6520010a2a333faba?d=identicon&s=25 R. Elliott Mason (eleo)
on 2007-06-27 16:12
There's nothing wrong with controllers that aren't directly related to a
model.  If there are methods multiple controllers will use then I would
think the best place to put them is in the application controller.
Anyway, it's a good idea to plan ahead, I think you're on the right
track.
413faf211358af7cae68c1f2137de0f8?d=identicon&s=25 Mel Riffe (Guest)
on 2007-06-27 16:13
(Received via mailing list)
Hi Will,

I would hide the external system behind a Model.  I view Controllers as
those things that manage the interactions between the 'things' in an
application.  An external system, as it appears, is another 'thing' in
your
application.

This gives you the ability to use this Model in other controllers, or
other
applications should the need arise.

However, I'm sure you'll get plenty of options from this list on which
to
choose a solution that fits your needs.

Cheers,
Mel Riffe
This topic is locked and can not be replied to.