I suggest you pick up a book and start following a tutorial. Otherwise you’ll spend most of your time here waiting for people to answer your questions. This becomes frustrating very quickly.
Trust me, it may seem easier to come here and ask extremely simple questions (the answers of which are obvious in the docs) but it’s not. In the long term, you’ll be thankful you took the extra few minutes to read and understand the docs. The books are extremely helpful and will answer most of your basic questions. I started learning Ruby and RoR about two weeks ago, and I’m very glad I took the time to read through and complete a tutorial.
Just visit amazon.com and type rails books and you’ll have a great selection to choose from. Also, try this, which I started with: http://ruby.railstutorial.org/chapters/static-pages --avoid the shortcuts and don’t rush. It pays off in the end.
I read the Rails Tutorial book, but I does not teach anything related to customizing that much, thats why I’m constantly search google and asking questions here (when I don’t find it on google).
I’m still searching google, but couldn’t find my answer for the current question.
Well, frankly, if I were you, I would read the documentation again. It doesn’t seem like you know what a polymorphic association is. You described a standard has_many relationship.
Polymorphic association is when one model belongs to several different models. For example, to use the Rails casts episode, a comment can belong to a Photo, a Post, or a Product.
From what you have written so far, it seems like you want a standard has_many and belongs_to association.
User has_many :posts will let you do @user.posts, and a Post belongs_to :user will let you do post.user. If you want customize the name of the association, as in post.author, then I think you need to use the :class_name
When you say you have read the rails tutorial book is that the one
that goes with railstutorial.org? If so then reading it is not
enough. Work right through it doing all the examples and so on. Make
sure you understand every line of code. You may think that the
application it develops is not what you want but that does not matter,
it will show you a wide range of techniques. Make sure that you have
installed the version of rails that matches that used by any tutorial
you use.
Don’t let that daunt you. I was in the same boat as you were not long ago. I’ll tell you what I did:
Completed http://ruby.railstutorial.org/ – twice! It does an awesome job of explaining things.
Rails for Zombies I, a screen cast series on codeschool.com (I think–you’ll have to google it).
Rails Casts
Rails Guides
I actually started with Programming Ruby 1.9, the Pragmatic Programmers Guide. I didn’t finish it. I read enough to get the basics of Ruby syntax. Knowing the Ruby syntax is essential since, to me, it looked nothing like anything I’ve seen before. Bracket were often omitted, and so were semi-colons, blocks, etc… understanding the syntax made understanding easier.
After getting through 200 pages, I switched to Agile Web Development with Rails 4th Ed. Frankly, I thought it was a waste of money at that point. It just told you to do stuff without explaining much of what you were doing. Especially when it came to testing. I quit and switched to Rails Tutorial. I don’t think it’s beginner friendly.Rails Tutorial I thought was brilliant. But it was hard to follow because of some issues. There was no mention that Heroku did not support SQLite for example. But the book does an awesome job of explaining the basics. Read it carefully. And it’s free.
I’m planning on Reading Rails AntiPatterns and The Rails 3 Way next…
I’ll second what Colin said. I’ll also emphasize the need to “hold your horses”. There’s nothing more frustrating than having to wade through a ton of stuff before you start building something. But it’s absolutely worth it, and it will save you a ton of time in the long run.
If I had spent 10% of my time reading documentation, I would have saved the other 90% that I wasted editing lines of code, scanning hurriedly over tutorials, asking a ton of questions, etc… it really is true. It’s frustrating at first, but it pays off and saves you a ton of time in the long term.