Presentation :belongs_to user means that Presentation has a column
called user_id which 'points to' a User. You dont have this.
And belongs_to isn't symmetrical, the other end needs a :has_many, or
:has_one relationship.
From what you started out saying there's one presentation for each
user, in which case the relations would be:
User
has_one :presentation
Presentation
belongs_to :user
with user_id field in the presentations table.
That said, has_one is almost never used like this, if there really is
a fixed one-one relationship between presentations and users then they
probably should be combined in one table. If, on the other hand, the
situation is that the User can have multiple presentations then you
might want something like:
User
has_many :presentations
has_one :current_presentation, :order => "updated_at DESC"
where the current_presentation uses the magic updated_at field to get
the most recently modified presentation.
From what you started out saying there's one presentation for each
user, in which case the relations would be:
User
has_one :presentation
Presentation
belongs_to :user
with user_id field in the presentations table.
Allright, well this at least did make the relations clearer, thanks
Rick.
Still I'm not very clear about how to create a new presentation with a
default value as a new user gets created (especially since the datatype
TEXT dosen't allow default values)?
by placing it in the UserController in the class definition "create"
(which already exists)but this only generates half of what I want to
accomplish:
new rows,
but sadly enough only NULL in the columns.
Now, all it does is it returns nil (I hate nil, btw because it's allways
so "unexpected").
The error msg beeing (http://localhost:3000/users):
"You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.create"