Forum: Ruby on Rails going crazy!!!!!! ActiveRecord::StatementInvalid in Project

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
ss (Guest)
on 2006-05-09 19:57
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?
Randal S. (Guest)
on 2006-05-09 20:09
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.
ss (Guest)
on 2006-05-09 20:25
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!
Randal S. (Guest)
on 2006-05-09 22:27
I remember reading somethign about QUOTE being a key word...  try
something else other than QUOTE.
Pete Y. (Guest)
on 2006-05-10 03:43
(Received via mailing list)
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
Daniel -. (Guest)
on 2006-05-10 03:52
(Received via mailing list)
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
ss (Guest)
on 2006-05-10 12:04
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

my quote .rb file begins with
class Quote < ActiveRecord::Base
ss (Guest)
on 2006-05-10 13:25
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
This topic is locked and can not be replied to.