# Data not being saved

**URL:** <https://www.ruby-forum.com/t/data-not-being-saved/153364>\
**Category:** Rails\
**Created:** [November 15, 2008, 8:08pm UTC](https://www.ruby-forum.com/t/data-not-being-saved/153364 "2008-11-15T20:08:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [November 15, 2008, 8:08pm UTC](https://www.ruby-forum.com/t/data-not-being-saved/153364/1 "2008-11-15T20:08:07Z")

</div>

I am trying to save data entered in a form and nothing seems to be  
saving. What do you I have to look at to ensure everything is set-up  
correctly? I have looked in my database.yml file and all looks good and  
the database that I am trying to use exist. Thanks,

-S

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [November 15, 2008, 8:31pm UTC](https://www.ruby-forum.com/t/data-not-being-saved/153364/2 "2008-11-15T20:31:07Z")

</div>

Shandy N. wrote:

> I am trying to save data entered in a form and nothing seems to be  
> saving. What do you I have to look at to ensure everything is set-up  
> correctly? I have looked in my database.yml file and all looks good and  
> the database that I am trying to use exist. Thanks,
> 
> -S

There should be a lot of good information in your log files like what  
was sent to the controller and what the sql for accessing the database  
looked like. It sounds like you did not get an error which means that  
your parameters and sql were ok. I would suspect you somehow are  
looking for your data in the wrong place.  
When you say it is not saving, do you mean that it is not fetched if you  
try to list it (or do something like a=Type.find :all in a  
script/console window).

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [November 15, 2008, 8:42pm UTC](https://www.ruby-forum.com/t/data-not-being-saved/153364/3 "2008-11-15T20:42:25Z")

</div>

Norm wrote:

> > 
> 
> There should be a lot of good information in your log files like what  
> was sent to the controller and what the sql for accessing the database  
> looked like. It sounds like you did not get an error which means that  
> your parameters and sql were ok. I would suspect you somehow are  
> looking for your data in the wrong place.  
> When you say it is not saving, do you mean that it is not fetched if you  
> try to list it (or do something like a=Type.find :all in a  
> script/console window).

Not really, this is what I see:

Processing AdminController#create\_user (for 127.0.0.1 at 2008-11-15  
12:39:02) [POST]  
Session ID: 055075e032051a9365cecbcbf4abb283  
Parameters: {“commit”=\>“Submit”,  
“post”=\>{“emailvrfy”=\>“removed\_email\_address@domain.invalid”, “passwordvrfy”=\>“test72”,  
“password”=\>“test72”, “email”=\>“removed\_email\_address@domain.invalid”},  
“action”=\>“create\_user”, “controller”=\>“admin”}  
e[4;35;1mUser Columns (0.007000)e[0m e[0mSHOW FIELDS FROM userse[0m  
e[4;36;1mSQL (0.003000)e[0m e[0;1mBEGINe[0m  
e[4;35;1mUser Load (0.000000)e[0m e[0mSELECT \* FROM users WHERE  
(users.email IS NULL) LIMIT 1e[0m  
e[4;36;1mSQL (0.000000)e[0m e[0;1mCOMMITe[0m  
Redirected to [http://localhost:3000/league/beginning](http://localhost:3000/league/beginning)  
Completed in 0.03700 (27 reqs/sec) | DB: 0.01000 (27%) | 302 Found  
[[http://localhost/admin/create\_user](http://localhost/admin/create_user)]

When I try and manually add a user through irb nothing even though it  
appears that it is saving. The only thing that I can guess is that it is  
being saved to another table somewhere but my .yml seems to think it is  
using the same table that I am looking at.

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [November 15, 2008, 9:08pm UTC](https://www.ruby-forum.com/t/data-not-being-saved/153364/4 "2008-11-15T21:08:22Z")

</div>

Frederick C. wrote:

> On Nov 15, 7:42ï¿½pm, Shandy N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > ï¿½ ï¿½[4;35;1mUser Load (0.000000) [0m ï¿½ ï¿½[0mSELECT \* FROM users WHERE  
> > (users.email IS NULL) LIMIT 1 [0m
> 
> this looks suspicious, (I’m guessing it’s a query from  
> validates\_uniqueness\_of) - it looks like your controller is looking  
> for params in the wrong place.  
> the logs show that nothing attempted to write the data at all, usually  
> this is because of a failed validation.
> 
> Fred

You are correct, I was validates\_uniqueness\_of :email and then not  
passing an email address. Thanks for the help, hope everyone is having a  
good weekend.

-S

---

<div class="post-metadata">

**Author:** ![snantz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@snantz](https://www.ruby-forum.com/u/snantz)\
**Post date:** [November 15, 2008, 8:49pm UTC](https://www.ruby-forum.com/t/data-not-being-saved/153364/5 "2008-11-15T20:49:17Z")

</div>

On Nov 15, 7:42 pm, Shandy N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> [4;35;1mUser Load (0.000000) [0m [0mSELECT \* FROM users WHERE  
> (users.email IS NULL) LIMIT 1 [0m

this looks suspicious, (I’m guessing it’s a query from  
validates\_uniqueness\_of) - it looks like your controller is looking  
for params in the wrong place.  
the logs show that nothing attempted to write the data at all, usually  
this is because of a failed validation.

Fred
