(Disclaimer: I am new to RoR, coming from developing in ASP.NET. I am
looking to start my next project in an open source environment to 1)
cut down on the costs of tools and hosting, and 2) to learn something
new. The runners up for “something new” are RoR and PHP.)
I’ve thumbed through RailsSpace a number of times so I know a
community site CAN be written in RoR. What I’m more interested in is
can the home page in say facebook, wherein there are numerous webparts
doing different things, be written in RoR? From what I’ve seen, and
what I’ve done using tutorials and books, is that RoR works
wonderfully for CRUD style pages. One page to view customers, and one
page to add/edit customers. But can one page be the host of multiple
views driven by multiple controllers? (Yes, my MVC experience is of
the newb level too. Sorry in advance.)
But can one page be the host of multiple views driven
by multiple controllers?
Yes. You can use a layout that’s a composite of / renders partials for
set of MVC components.
(Yes, my MVC experience is of the newb level too.
Sorry in advance.)
IME, the only ‘tricky’ part of maintaining the MVC pattern here is the
approach you use to populate the partials when you display the
page. One approach is to have a method in application.rb that grabs the
content for each of the partials. That gives you an application-wide
controller method feeding content to an application-wide view. There
of course, other approaches and you should feel free to make use of
whichever is most appropriate to your situation. MVC is a very good
but it’s not something that has to be adhered to in every case.
I’ve found an interesting discussion of this ‘problem’ with a
potential approach on
Don’t forget to download the 10 page pdf at the top of the article,
that’s the main part!
I don’t think MVC stands in the way of building the Facebook home
page. Even in Facebook, there is a main view that takes up most space
(when you log in that’s the news feed). From there your layout pulls
in many partials to fill the right column. If you’re very consistent
in your layout, instead of having to fill in all the content in every
action of your controller, you do that in your ApplicationController.
Or in a more complex site with different main layouts, you can
structure your controllers by namespacing them and put common code in
the top of the hierarchy.
But if you look at the Facebook site, it’s just the home page that is
fairly complex because it contains infromation from a lot of different
models (in RoR terms it seems to be calling many index actions from
many controllers). But all other pages are very focused on what the
user actually wants to do and can be easily handled in the simple MVC
It’s actually quite good to build an application focusing on one main
view, this gives the user also a sense of focus. An application with 4
views all of equal importance doesn’t seem right to me (except for the
iGoogle type of dashboards…).
Two resources that might help you with it are published and to be
published by PeepCode and Pragmatic Programmers respectively. Here
are the links:
- Peepcode: - You will see that they have published a Rails on
Facebook PDF. I haven’t had the time to look at it yet so I don’t
know how much it will help you.
- Pragmatic Programmers:
Pragmatic Bookshelf: By Developers, For Developers
This book is about to be released.
You may find these two resources helpful.
Thanks everyone! The article deegee posted seems to go over what I’ve
been looking for, a 3 column layout that can be filled from different
sources. And the Rails on Facebook has given me some ideas as well.