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?
Share
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