Trouble saving current user

I have an application where users can log in and create records. I am trying to get Rails to save the id/name of the user who created the record. Somehow, the user id isn't getting stored, and I can't tell why.

I'm rather new to Rails, and I'm cobbling together different tips from different tutorials (and advice from friendly people here), and my guess is that I've just mushed too much stuff together and don't know how to integrate it all gracefully. Or, just as likely, there's some glaring typo in my code.

In any case, here is the relevant part of the controller:

---------------------words_controller.rb------------------- class WordsController < ApplicationController    before_filter :login_required, :only => [ :new, :create, :edit, :update, :delete ] ....    def new       @word = Word.new    end    def create       @modword = (Modword.find_by_modspell(params[:modword][:modspell])

Modword.create(params[:modword]))

      @word = @current_user.words.build(params[:word])       @word = Word.new(params[:word].merge(:modword_id => @modword.id))         if @word.save           redirect_to(:action => :index)         else           render :action => 'new'       end    end .... end

You could also do: