Foreign keys

I have a building a very simple app with which to learn Rails where a user can create as many CVs (resumes) as they wish.

For now I have:

ActiveRecord::Schema.define(:version => 4) do

  create_table "cvs", :force => true do |t|     t.column "uni", :string     t.column "class", :string     t.column "degree", :string     t.column "user_id", :integer   end

  create_table "users", :force => true do |t|     t.column "first_name", :string     t.column "last_name", :string   end

end

In the 'cv' model I have:

class Cv < ActiveRecord::Base belongs_to :user end

in the 'user' model I have:

class User < ActiveRecord::Base has_many :cvs end

I've added my controller code at the end of the message in case that helps.

When I come to code the view for creating a new cv I want the new CV that is created to have the 'user_id' as the foreign key. But I just cannot work out what code to write.

I have been trying even to get the user's name to appear in the createcv view but failed:

<h1><%= params[:action].capitalize %> CV</h1>

This is <%= @user.user.first_name %>

<%= start_form_tag :action => 'create' %> <b>Enter your degree title</b><br />     <%= text_field ('cv', 'degree') %><br /> <b>Enter expected/achieved class</b><br />     <%= text_field ('cv', 'class') %><br /> <b>Enter institution name</b><br />     <%= text_field ('cv', 'uni') %><br />

    <%= submit_tag 'Save' %>

<%= end_form_tag %>

I guess I am just confused by routing.

I know this is incredibly simple and yet I have been through the 4 books I have, all of them on Ruby and Rails ;-), various online tutorials and yet somehow I just cannot work out how to do this.

If someone could explain it to my like I was 5 then maybe I'd get it.

Thanks

Ambrose

cv-controller

anyone have a moment - this must be so simple!