# Nothing is being inserted into the database...help!

**URL:** <https://www.ruby-forum.com/t/nothing-is-being-inserted-into-the-database-help/194418>\
**Category:** Rails\
**Created:** [September 4, 2010, 9:23pm UTC](https://www.ruby-forum.com/t/nothing-is-being-inserted-into-the-database-help/194418 "2010-09-04T21:23:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jakx12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jakx12](https://www.ruby-forum.com/u/jakx12)\
**Post date:** [September 4, 2010, 9:23pm UTC](https://www.ruby-forum.com/t/nothing-is-being-inserted-into-the-database-help/194418/1 "2010-09-04T21:23:52Z")

</div>

Hello all,

for some reason nothing is being inserted into the database. I have no  
idea why not! Here is my action:

def create  
@information = CalorieKing.new  
@information = CalorieKing.get\_information(params[:id])  
@information = @information[‘food’][‘servings’]  
@information[‘serving’].each do |s|  
if s[‘name’] == params[:portion\_type]  
s[‘nutrients’].each do |value|  
value \*= params[:size]  
end  
puts ‘hello’  
@foodentry = FoodEntry.new(:user\_id =\> current\_user.id,  
:name =\> s[‘name’], :serving\_size =\> params[:size],  
:serving\_name =\> params[:portion\_type], :calories =\>  
s[‘nutrients’][‘caloires’],  
:fat =\> s[‘nutrients’][‘fat’], :carbs =\> s[‘nutrients’][‘carb’],  
:protein =\> s[‘nutrients’][‘protein’], :fiber =\>  
s[‘nutrients’][‘fiber’],  
:sugar =\> s[‘nutrients’][‘sugar’], :sodium =\>  
s[‘nutrients’][‘sodium’],  
:calcium =\> s[‘nutrients’][‘calcium’], :satfat =\>  
s[‘nutrients’][‘satfat’],  
:cholesterol =\> s[‘nutrients’][‘cholesterol’])  
@foodentry.save  
puts ‘hello’  
end  
end  
respond\_to do |format|  
format.html { redirect\_to(food\_diary\_path) }  
format.xml { head :ok }  
end  
end

Thanks!

---

<div class="post-metadata">

**Author:** ![jakx12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jakx12](https://www.ruby-forum.com/u/jakx12)\
**Post date:** [September 4, 2010, 11:58pm UTC](https://www.ruby-forum.com/t/nothing-is-being-inserted-into-the-database-help/194418/2 "2010-09-04T23:58:57Z")

</div>

> for some reason nothing is being inserted into the database. I have no  
> idea why not! Here is my action:

The most common cause is that validations are failing, and you’re just  
not seeing that.

– gw

---

<div class="post-metadata">

**Author:** ![jakx12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jakx12](https://www.ruby-forum.com/u/jakx12)\
**Post date:** [September 5, 2010, 12:14am UTC](https://www.ruby-forum.com/t/nothing-is-being-inserted-into-the-database-help/194418/3 "2010-09-05T00:14:32Z")

</div>

And your controller should be put on a diet…

–

[http://digiprof.tv](http://digiprof.tv)

---

<div class="post-metadata">

**Author:** ![jakx12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jakx12](https://www.ruby-forum.com/u/jakx12)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/nothing-is-being-inserted-into-the-database-help/194418/4 "2010-09-06T16:39:49Z")

</div>

On 4 Sep, 20:23, Zack N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hello all,
> 
> for some reason nothing is being inserted into the database. I have no  
> idea why not! Here is my action:

Did you check for any validations failing

Fred

---

<div class="post-metadata">

**Author:** ![jakx12](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jakx12](https://www.ruby-forum.com/u/jakx12)\
**Post date:** [September 7, 2010, 12:34am UTC](https://www.ruby-forum.com/t/nothing-is-being-inserted-into-the-database-help/194418/5 "2010-09-07T00:34:20Z")

</div>

Frederick C. wrote:

> On 4 Sep, 20:23, Zack N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hello all,
> > 
> > for some reason nothing is being inserted into the database. I have no  
> > idea why not! Here is my action:
> 
> Did you check for any validations failing
> 
> Fred

Yep sorry, Iv been busy and hadnt checked my email for replies. You guys  
were right I had a type in the name of my validation so i fixed it and  
now it works great! Of course my controller needs to loose some weight,  
i just need to get the app working and show the client a working copy  
then im going refractor pretty much all my code!
