# Simple Newbie db?

**URL:** <https://www.ruby-forum.com/t/simple-newbie-db/102198>\
**Category:** Rails\
**Created:** [August 12, 2006, 6:10pm UTC](https://www.ruby-forum.com/t/simple-newbie-db/102198 "2006-08-12T18:10:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chasconquest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/bb73d2/32.png) [@chasconquest](https://www.ruby-forum.com/u/chasconquest)\
**Post date:** [August 12, 2006, 6:10pm UTC](https://www.ruby-forum.com/t/simple-newbie-db/102198/1 "2006-08-12T18:10:09Z")

</div>

I’m trying to simply write to a mysql db from the console.  
Model = Entry , table = entries

Problem is my values keep getting turned into instance variables and end  
up nil.

> > Entry.create(:title =\>“new title”, :body =\> “Brand new body”)  
> > =\> #\<Entry:0x27178c4 @attributes={“body”=\>nil, “title”=\>nil, “id”=\>6},  
> > @body=“Brand new body”, @title=“new title”, @new\_record=false,  
> > @errors=#\<ActiveRecord::Errors:0x2716d0c @base=#\<Entry:0x27178c4 …\>,  
> > @errors={}\>\>

Also tried… \>\> Entry.create(“title” =\>“new title”, “body” =\> “Brand new  
body”)

Any clues?

Other tables in same db are fine…

TIA

Chas

---

<div class="post-metadata">

**Author:** ![chasconquest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/bb73d2/32.png) [@chasconquest](https://www.ruby-forum.com/u/chasconquest)\
**Post date:** [August 12, 2006, 8:41pm UTC](https://www.ruby-forum.com/t/simple-newbie-db/102198/2 "2006-08-12T20:41:08Z")

</div>

Hmmm…

created another table called “dogs”  
created a model dog.rb - “Class Dog”

everything works fine…

Then I migrated down to before Entry / entries (Class - table)

renamed em Entry entrys (Class - table)  
no go…  
active record wants “entries”…

---

<div class="post-metadata">

**Author:** ![chasconquest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/bb73d2/32.png) [@chasconquest](https://www.ruby-forum.com/u/chasconquest)\
**Post date:** [August 13, 2006, 8:40am UTC](https://www.ruby-forum.com/t/simple-newbie-db/102198/3 "2006-08-13T08:40:38Z")

</div>

Chas,

What’s the log?

---

<div class="post-metadata">

**Author:** ![chasconquest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/bb73d2/32.png) [@chasconquest](https://www.ruby-forum.com/u/chasconquest)\
**Post date:** [August 13, 2006, 1:34pm UTC](https://www.ruby-forum.com/t/simple-newbie-db/102198/4 "2006-08-13T13:34:29Z")

</div>

Hi Chas,

You can always use:

class Entry \< ActiveRecord::Base  
set\_table\_name ‘entrys’  
end

Using this method you can call your tables whatever you like. Does not  
play well with migrations though.

Phil

Chas C. wrote:

> Hmmm…
> 
> created another table called “dogs”  
> created a model dog.rb - “Class Dog”
> 
> everything works fine…
> 
> Then I migrated down to before Entry / entries (Class - table)
> 
> renamed em Entry entrys (Class - table)  
> no go…  
> active record wants “entries”…

---

<div class="post-metadata">

**Author:** ![chasconquest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/bb73d2/32.png) [@chasconquest](https://www.ruby-forum.com/u/chasconquest)\
**Post date:** [August 15, 2006, 5:52pm UTC](https://www.ruby-forum.com/t/simple-newbie-db/102198/5 "2006-08-15T17:52:58Z")

</div>

Mat S. wrote:

> On Aug 12, 2006, at 12:10 PM, Chas C. wrote:
> 
> > @errors=#\<ActiveRecord::Errors:0x2716d0c @base=#\<Entry:0x27178c4 …\>,  
> > @errors={}\>\>
> 
> Are body and title the right type in the database? If other models  
> work I’d think the underlying table is the issue. I’m also going  
> with this because “id” came back from the db fine, but the other two  
> didn’t, which makes it seem like the database is throwing it away.  
> -Mat

Thanks guys, got it sorted out.

---

<div class="post-metadata">

**Author:** ![chasconquest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/bb73d2/32.png) [@chasconquest](https://www.ruby-forum.com/u/chasconquest)\
**Post date:** [August 15, 2006, 2:18pm UTC](https://www.ruby-forum.com/t/simple-newbie-db/102198/6 "2006-08-15T14:18:23Z")

</div>

On Aug 12, 2006, at 12:10 PM, Chas C. wrote:

> @errors=#\<ActiveRecord::Errors:0x2716d0c @base=#\<Entry:0x27178c4 …\>,  
> @errors={}\>\>

Are body and title the right type in the database? If other models  
work I’d think the underlying table is the issue. I’m also going  
with this because “id” came back from the db fine, but the other two  
didn’t, which makes it seem like the database is throwing it away.  
-Mat
