views:

67

answers:

2

I'm coming from the .NET world, and I'm trying to figure out the "Rails way" to design software. In ASP.NET, my usual instinct is to think in terms of pages. Very often I'll start with default.aspx (the main or index page) and build off that. But under Rails, that seems wrong.

On the main page for my app, I want to show a list of items. It seems like I should probably create a resource to represent an item, and the site's main page should be the view for the index action of the resource's controller. Am I looking at this the right way?

To me, this seems better than creating some kind of .erb file or something that's just floating out there disconnected.

Please forgive me if I've abused Rails terms I don't fully understand yet.

A: 

You seem to have two different questions wrapped up here:

  1. What's the best way to create a "homepage" with RoR

  2. How should I think about creating my RoR app?

The first you can Google and find tons of tutorials on, the second is tougher to get your head around.

I'd recommend starting with the Models that make up your application, think through how they relate and play around with them before you actually start to write pages.

Something neat in Rails is "script/console", type that into the root directory of your application (from a command line) and you'll be able to test and play around with the models directly.

Mike Buckbee
+1  A: 

The main page is just a view; you can choose a controller as home controller or you can map root to whatever view you prefer.

map.root :controller => "mycontroller", :action => "myaction"

or

map.root :controller => "home"

It's up to you: if you want to show some resources, go for the first; if you want to just show an intro page, go for the second.

giorgian