# Going crazy! ActiveRecord::StatementInvalid in Project

**URL:** <https://www.ruby-forum.com/t/going-crazy-activerecord-statementinvalid-in-project/94635>\
**Category:** Rails\
**Created:** [May 9, 2006, 5:57pm UTC](https://www.ruby-forum.com/t/going-crazy-activerecord-statementinvalid-in-project/94635 "2006-05-09T17:57:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssssss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@ssssss](https://www.ruby-forum.com/u/ssssss)\
**Post date:** [May 9, 2006, 5:57pm UTC](https://www.ruby-forum.com/t/going-crazy-activerecord-statementinvalid-in-project/94635/1 "2006-05-09T17:57:50Z")

</div>

any suggestions on why I am gaining this error.

ActiveRecord::StatementInvalid in ProjectsController#create

Mysql::Error: You have an error in your SQL syntax; check the manual  
that corresponds to your MySQL server version for the right syntax to  
use near ’ , , , , )’ at line 1: INSERT INTO projects (`name`,  
`date_created`, `quote_id`, `client_id`, `description`, `user_id`)  
VALUES(, , , , , )

all seem sto go wrong when I call  
if @project.save

however when I change  
belongs\_to :quote to belongs\_to :quotes (extra s on the end)

Everything seems to work here as expected.

any suggestions why thi sis happening?

---

<div class="post-metadata">

**Author:** ![ssssss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@ssssss](https://www.ruby-forum.com/u/ssssss)\
**Post date:** [May 9, 2006, 6:09pm UTC](https://www.ruby-forum.com/t/going-crazy-activerecord-statementinvalid-in-project/94635/2 "2006-05-09T18:09:36Z")

</div>

Does a project belong to many quotes?

As for the mySQL error, you’re not submitting any data with the call…  
I’m assuming the ids can’t be empty.

Make sure you’re setting everythign that needs to be set before you  
insert… it looks like you’re inserting an empty row.

---

<div class="post-metadata">

**Author:** ![ssssss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@ssssss](https://www.ruby-forum.com/u/ssssss)\
**Post date:** [May 9, 2006, 8:27pm UTC](https://www.ruby-forum.com/t/going-crazy-activerecord-statementinvalid-in-project/94635/3 "2006-05-09T20:27:05Z")

</div>

I remember reading somethign about QUOTE being a key word… try  
something else other than QUOTE.

---

<div class="post-metadata">

**Author:** ![ssssss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@ssssss](https://www.ruby-forum.com/u/ssssss)\
**Post date:** [May 9, 2006, 6:25pm UTC](https://www.ruby-forum.com/t/going-crazy-activerecord-statementinvalid-in-project/94635/4 "2006-05-09T18:25:12Z")

</div>

Randal S. wrote:

> Does a project belong to many quotes?
> 
> As for the mySQL error, you’re not submitting any data with the call…  
> I’m assuming the ids can’t be empty.
> 
> Make sure you’re setting everythign that needs to be set before you  
> insert… it looks like you’re inserting an empty row.

no quotes.rb  
has\_one :project

and project.rb  
belongs\_to :quote

with the forign field quote\_id being in the project table

As far as I ama aware everything is set up, I even define

@project.date\_created = Time.now  
before project.save and this does not get included.

if i remove the has\_one and belongs to, everything works fine!

---

<div class="post-metadata">

**Author:** ![ssssss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@ssssss](https://www.ruby-forum.com/u/ssssss)\
**Post date:** [May 10, 2006, 1:52am UTC](https://www.ruby-forum.com/t/going-crazy-activerecord-statementinvalid-in-project/94635/5 "2006-05-10T01:52:08Z")

</div>

If you generated the model / controller with the command

./ script/generate scaffold quote

I believe it makes it into quotes. Check your quote model file.

If it says

class Quotes \< ActiveRecord::Base  
…

The you need to use belongs\_to :quotes

---

<div class="post-metadata">

**Author:** ![ssssss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@ssssss](https://www.ruby-forum.com/u/ssssss)\
**Post date:** [May 10, 2006, 1:43am UTC](https://www.ruby-forum.com/t/going-crazy-activerecord-statementinvalid-in-project/94635/6 "2006-05-10T01:43:03Z")

</div>

On 10/05/2006, at 2:25 AM, ss wrote:

> no quotes.rb  
> Shouldn’t this be quote.rb? Is your model class called Quote or  
> Quotes? It should be Quote.

Pete Y.  
[http://9cays.com](http://9cays.com)

---

<div class="post-metadata">

**Author:** ![ssssss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@ssssss](https://www.ruby-forum.com/u/ssssss)\
**Post date:** [May 10, 2006, 11:25am UTC](https://www.ruby-forum.com/t/going-crazy-activerecord-statementinvalid-in-project/94635/7 "2006-05-10T11:25:14Z")

</div>

Randal S. wrote:

> I remember reading somethign about QUOTE being a key word… try  
> something else other than QUOTE.

I have taken a look at this and renamed everything, and it all seems to  
work now, however I couldnt find this word on any reserved keyword list.

Could this be a bug or just not documented?

a bit of digging also led to this post

[http://www.ruby-forum.com/topic/151#488](http://www.ruby-forum.com/topic/151#488)

---

<div class="post-metadata">

**Author:** ![ssssss](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8dc957/32.png) [@ssssss](https://www.ruby-forum.com/u/ssssss)\
**Post date:** [May 10, 2006, 10:04am UTC](https://www.ruby-forum.com/t/going-crazy-activerecord-statementinvalid-in-project/94635/8 "2006-05-10T10:04:53Z")

</div>

Pete Y. wrote:

> On 10/05/2006, at 2:25 AM, ss wrote:
> 
> > no quotes.rb  
> > Shouldn’t this be quote.rb? Is your model class called Quote or  
> > Quotes? It should be Quote.
> 
> Pete Y.  
> [http://9cays.com](http://9cays.com)

my quote .rb file begins with  
class Quote \< ActiveRecord::Base
