# Rails inserting NULL values instead of actual values

**URL:** <https://www.ruby-forum.com/t/rails-inserting-null-values-instead-of-actual-values/175049>\
**Category:** Rails\
**Created:** [September 7, 2009, 1:32am UTC](https://www.ruby-forum.com/t/rails-inserting-null-values-instead-of-actual-values/175049 "2009-09-07T01:32:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 7, 2009, 1:32am UTC](https://www.ruby-forum.com/t/rails-inserting-null-values-instead-of-actual-values/175049/1 "2009-09-07T01:32:34Z")

</div>

I have an odd issue that I am having a difficult time solving.

When I attempt to create or edit data in my rails app; it INSERTs NULL  
values instead of the values I eintered in the form. Same with editing  
the data; it doesn’t UPDATE the table with values I entered. Via the  
console, I can see that it recieved the values but the SQL statements  
show NULL values.

I don’t know where my problem lies. Here’s my code below. Any help  
would be greatly appreciated. Thanks!

Console error  
[http://dpaste.com/90452/](http://dpaste.com/90452/)

meetmes\_controller.rb  
[http://dpaste.com/90453/](http://dpaste.com/90453/)

meetme.rb Model (nothing in here)  
[http://dpaste.com/90454/](http://dpaste.com/90454/)

meetme view (new)  
[http://dpaste.com/90455/](http://dpaste.com/90455/)

meetme view (edit)  
[http://dpaste.com/90456/](http://dpaste.com/90456/)

Michael

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 7, 2009, 2:22am UTC](https://www.ruby-forum.com/t/rails-inserting-null-values-instead-of-actual-values/175049/2 "2009-09-07T02:22:54Z")

</div>

On Sun, Sep 6, 2009 at 3:59 PM, Michael R[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> When I attempt to create or edit data in my rails app; it INSERTs NULL  
> values instead of the values I eintered in the form.

> meetmes\_controller.rb

def create  
@meetme = Meetme.new(params[:meetmes])

> meetme view (new)

\<% form\_for(@meetme) do |f| %\>

Singular/plural mismatch? that is, shouldn’t it be  
@meetme = Meetme.new(params[:meetme]) # to match your form

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 7, 2009, 9:51am UTC](https://www.ruby-forum.com/t/rails-inserting-null-values-instead-of-actual-values/175049/3 "2009-09-07T09:51:46Z")

</div>

Hello Micheal,

when using formfor, the returned parameter’s name is the same as the  
model’s name, but in your create action you are retrieving “meetmes”  
instead of “meetme” from the parameters (which is nil) so the new  
method would instantiate an empty model and then try to save it.

try this create action instead of the one you have:

def create  
@meetme = Meetme.new(params[:meetme]) # notice this line

```
respond_to do |format|
  if @meetme.save
    flash[:notice] = 'Meetmes was successfully created.'
    format.html { redirect_to(@meetme) }
    format.xml { render :xml => @meetme, :status

```

=\> :created, :location =\> @meetme }  
else  
format.html { render :action =\> “new” }  
format.xml { render :xml =\> @meetme.errors, :status  
=\> :unprocessable\_entity }  
end  
end  
end

Cheers…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 8, 2009, 4:30pm UTC](https://www.ruby-forum.com/t/rails-inserting-null-values-instead-of-actual-values/175049/4 "2009-09-08T16:30:20Z")

</div>

Thanks Hasson, cousine! That fixed my problem. I appreciate the quick  
responses.

Michael
