# 15 minute RoR blog help

**URL:** <https://www.ruby-forum.com/t/15-minute-ror-blog-help/111514>\
**Category:** Rails\
**Created:** [August 8, 2007, 6:12am UTC](https://www.ruby-forum.com/t/15-minute-ror-blog-help/111514 "2007-08-08T06:12:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mariko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecc23a/32.png) [@mariko](https://www.ruby-forum.com/u/mariko)\
**Post date:** [August 8, 2007, 6:12am UTC](https://www.ruby-forum.com/t/15-minute-ror-blog-help/111514/1 "2007-08-08T06:12:18Z")

</div>

Hello,

I’m a newbie to rails, ruby, and web development in general, and I’m  
having trouble with belongs\_to and has\_xxx relationships.

For example, right now I’m trying to get the 15 minute blog which is  
listed on the page to work, and when I try to post a comment, I’m  
getting this message:

“Couldn’t find Post without an ID”

Also, when I try and scaffold the comments attribute, post\_id does not  
show up on the list. However, it seems to be there when I look at the  
schema file:

create\_table “comments”, :force =\> true do |t|  
t.column “body”, :text  
t.column “post\_id”, :integer  
end

I’m thinking the post\_id attribute not showing up as a parameter when I  
run the scaffold and the “Couldn’t find Post without an ID” is related.

This is the code in the controller:

def comment  
Blogitem.find(params[:id]).comments.create(params[:comment])  
flash[:notice] = “Added your comment”  
redirect\_to :action =\> “show”, :id =\> params[:id]  
end

And this is the code that I’m trying to run:

\<%= form\_tag :action =\> “comment”, :id =\> @post %\>  
\<%= text\_area “Comment”, “body” %\>  
  
\<%= submit\_tag “Comment!” %\>

Very concrete help is really appreciated, since I’m quite new at both  
rails and ruby. Also, does anyone know where I can find the source code  
to the 15 minute blog? I keep checking and double checking my  
code/databases/etc. against what’s in the video but I’m not seeing the  
problem. Thank you very much!

---

<div class="post-metadata">

**Author:** ![mariko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecc23a/32.png) [@mariko](https://www.ruby-forum.com/u/mariko)\
**Post date:** [August 8, 2007, 10:44am UTC](https://www.ruby-forum.com/t/15-minute-ror-blog-help/111514/2 "2007-08-08T10:44:10Z")

</div>

Mariko, note that your error message says:

“Couldn’t find Post without an ID”

Which means that ActiveRecord has been asked to go find a Post, but no  
id was supplied. When you create a default model in a migration with  
Rails like:

create\_table :posts do |t|  
t.column :some\_column, :string  
end

you will also get - automatically - a column called “id”. Just plain  
“id”. Of course you also get your Post model and a bunch of other  
stuff for free. In you Comment model (comments table) the column  
called “post\_id” is how Rails goes and finds the relevant Post object  
in their belongs\_to relationship.

So a few things to look at:  
(a) Suggest you use the form\_for version of forms tags when using a  
model, rather than form\_tag, it does more for you.  
(b) Your view is refering to @post, but i see nothing that sets than  
instance variable in your controller  
(c) So I suspect the error you’re getting, assuning its when you  
“submit” is that your find() is failing because no “id” is set. But  
again, not the error is referring to the “id” column on the Post  
object - not the “post\_id” column on the Comment object.

A bit hard to tell from the elements of code you submitted. Happy to  
take a quick look if you email the model, controller and view to me at  
kipcole9 -at- gmail dot you-know-what.

Cheers, --Kip

On Aug 8, 12:12 pm, “Mariko C.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
