views:

274

answers:

7

I have done some work with Ruby on Rails but am still not comfortable writing a Rails app from scratch. My problem is that I am not able understand how to get the right model going when trying to write the application from scratch. I thought seeing the code of a complete existing application may help but am not sure. What should be the way to go for me?

+8  A: 

Get the book Agile Web Development with Rails. It goes through an entire example. It was really helpful for me when learning RoR. Available as both PDF and hardcopy.

tvanfosson
They just released the third edition last month, which covers up to Rails 2.2. Rails 2.3 came out right around the same time and there's a page that tracks the differences between the book and 2.3, of which there are only a few.
MattC
In my opinion, this book is the best book to learn
marcgg
+2  A: 

I second that book choice I would also recommend checking out these resources:

PeepCode Screencasts Peepcode is not free but Geoffrey has some really really great rails screencasts including a series targeted at getting started with rails that is well worth the investment.

Railscasts These are free screencasts on a wide range of rails specific topics which will are a great resource for when you want to learn how to do something specific in your app.

I'd also say that when you are learning rails you will only get so far before you need to focus on learning ruby too. Rails takes advantage of some ruby features which may be unfamiliar to you if you are coming from another non-dynamic language. So it's worth checking out some ruby learning resources this book is a great one for learning rails and ruby at the same time: Ruby for Rails by David Black

paulthenerd
+3  A: 

Apart from getting the book, watching the screencasts, reading the Rails Guides, you still need to actually make something of your own.

Accept this: you're going to make mistakes. That's OK, everybody else makes mistakes too. You're going to make the wrong models, create the wrong methods, the wrong tables with the wrong columns and that's OK too. You'll be doing the best you can and you'll get better. As your understanding - or Rails and of your application - improves so you'll see where you made mistakes and you'll fix them. (Or you'll give up!)

If you don't know what model to build first, try something like this: write a short description of your application as you currently understand it. Three or four sentences at most. Then look at your description and pick what seems to be the most important "thing". Try making that your first model.

So for a blog (sigh) application, you might write something like this (it doesn't have to be perfect, just write something):

"This app lets me write blog posts and publish them. Readers can post comments. I can remove comments I don't like".

The most important "object" there is probably "posts". So start with

ruby script/generate model Post
Mike Woodhouse
A: 

start small, do something simple

a todo list a simple blog twitter clone (lol)

Ed
A: 

I'd say agile web development with rails is the best call. The version 3 got released recently

Then try creating a simple application and don't be afraid to restart from scratch a couple of time if you find a better way to design your application

marcgg
A: 

There is an excellent free online tutorial to Restful Rails applications @ http://www.b-simple.de/documents Moreover, its in english, german & spanish, at the same price!

It is clear & effective. It has a few mistakes, but nothing blocking...

Mike Aski
A: 

The best way to learn something is to practice it. Think of a good project (not necessarily a useful one, just something interesting) and then just make it. Don't sweat over the details.

It doesn't matter if it doesn't work; Just throw it away and start again. With each new iteration/project you will learn and remember more.

Nathan