Activerecord.save attributes not saved

Hi there,

I just added two new attributes, created (datetime) and user_id in a db
entity called documents. Those two new attributes are not being saved to
the
db by the activerecord model ‘document’, they remain null after @
document.save. I tried restarting the server, but the problem remains
the
same

Model :

class Document < ActiveRecord::Base
has_many :tag_actions
has_one :user
end

Controller create method

def create
@document = Document.new
@document.title = params[:document][‘title’]
@document.body = params[:document][‘body’]
@document.created = DateTime.now.strftime(“Y-%m-%d %H:%M:%S”)
@document.user = User.find(session[:user_id])
if @document.save
flash[:notice] = ‘Document was successfully created.’
else
flash[:notice] = ‘Could not create document.’
end
redirect_to :action => ‘list’
end

you should have:

class Document < ActiveRecord::Base
belongs_to :user
has_many :tag_actions

end

class User < ActiveRecord::Base
has_many :documents

end

also, if you use the magic db field name ‘created_on’ of type datetime
(i’m
making the assumption you are using mysql), the datetime value for this
field will automatically be generated by AR upon creating the record.

def create
@document = Document.new(@params[:document])
@document.user_id = @session[:user_id]
if @document.save
flash[:notice] = “Document was successfully created”
redirect_to :action => :list
else
flash.[:notice] = “Could not create document”
render :action => :new
end
end