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
On 12/12/05, Sergi Borras
<aedesis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> 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
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
>
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails