Getting Foreign Key to work!

Okay. So I have this simple site, which includes Recipes and then
Comments.

I want ppl to be able to comment on the recipes, and so I made comments
have a recipe_id as it's foreign key etc. I'm not that much of a noob
to not know that stuff.

When I click on a recipe, and then make a new comment and click 'submit'
(for the comment) it submits it, but it still has recipe_id as nil! I
know how to make the comment know that it's for that particular recipe
through the command line, i.e.:

c = Comment.find(1)
r = Recipe.find(1)
r.comments << c
r.save

But how do I make my site do that automatically when I click the submit
button? I've been trying for DAYS.. Please help me.! Thank you so
much.