# Why isn't data being saved to the database?

**URL:** <https://www.ruby-forum.com/t/why-isnt-data-being-saved-to-the-database/193638>\
**Category:** Rails\
**Created:** [August 20, 2010, 10:20pm UTC](https://www.ruby-forum.com/t/why-isnt-data-being-saved-to-the-database/193638 "2010-08-20T22:20:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 20, 2010, 10:20pm UTC](https://www.ruby-forum.com/t/why-isnt-data-being-saved-to-the-database/193638/1 "2010-08-20T22:20:34Z")

</div>

I’m following an example in the “Head First Rails” book.

Now, when I “create” a record, and then go to the table, I find that a  
BLANK record is created also I enter field values.

What may I be missing?

This is how “advs\_controller.rb” looks like:

class AdvsController \< ApplicationController  
def show  
@adv = Adv.find(params[:id])  
end

def index  
@advs = Adv.find(:all)  
end

def new  
@adv = Adv.new(params[:ad])  
end

def create  
@adv = Adv.new(params[:ad])  
@adv.save  
end  
end

Thanks.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 20, 2010, 10:28pm UTC](https://www.ruby-forum.com/t/why-isnt-data-being-saved-to-the-database/193638/2 "2010-08-20T22:28:09Z")

</div>

I don’t know your view’s code, but looking at your controller’s code…  
maybe instead of params[:ad] you should use params[:adv] “maybe” I’m  
just  
guessing. you should send your view’s code

2010/8/20 Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 20, 2010, 10:33pm UTC](https://www.ruby-forum.com/t/why-isnt-data-being-saved-to-the-database/193638/3 "2010-08-20T22:33:19Z")

</div>

Thanks a lot Sergio. You are correct. It should have been:

@adv = Adv.save(params[:adv])
