# Creating a default, empty row in Table with user\_id fails

**URL:** <https://www.ruby-forum.com/t/creating-a-default-empty-row-in-table-with-user-id-fails/131151>\
**Category:** Rails\
**Created:** [March 6, 2008, 2:16pm UTC](https://www.ruby-forum.com/t/creating-a-default-empty-row-in-table-with-user-id-fails/131151 "2008-03-06T14:16:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaizerkaizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/45deac/32.png) [@kaizerkaizer](https://www.ruby-forum.com/u/kaizerkaizer)\
**Post date:** [March 6, 2008, 2:16pm UTC](https://www.ruby-forum.com/t/creating-a-default-empty-row-in-table-with-user-id-fails/131151/1 "2008-03-06T14:16:21Z")

</div>

Hi, I’m stuck with something quite easy. I’ve done this before to create  
an empty row in a table connected to a current\_user…and that looks  
like this (placed in the user\_controller’s create method):

# Creating a default, empty row in Presentations Table

@presentation = current\_user.presentation  
@presentation = current\_user.create\_presentation unless @presentation

# Creating a default, empty row in Entries Table

@entry = current\_user.entry  
@entry = current\_user.create\_entry unless @entry

Then I added a third table called Specs and wanted to create the same  
thing.

@spec = current\_user.spec  
@spec = current\_user.create\_spec unless @spec

But it refuses to create an empty row in the table connected to a  
user\_id…

Can’t understand why…  
Models involved are: User.rb & Spec.rb  
###################################################  
class User \< ActiveRecord::Base #class definition  
has\_one :spec  
has\_one :presentation  
has\_one :entry

###################################################  
class Spec \< ActiveRecord::Base  
belongs\_to :user

###################################################  
(the specs table works as long as I manually insert the user\_id and  
whitespace)  
###################################################  
create\_table “specs”, :force =\> true do |t|  
t.column “user\_id”, :integer  
t.column “first\_name”, :string  
t.column “last\_name”, :string  
t.column “gender”, :string  
t.column “occupation”, :string  
t.column “brithdate”, :datetime  
t.column “city”, :string  
t.column “country”, :string  
t.column “zip\_code”, :string

####################################################

please, this such a stupid error…anyone provide me with a solution  
…I’m going blind by my own code
