Forum: Ruby on Rails strange mysql problem

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.
E838033880a1e55e90f817f5b24a960b?d=identicon&s=25 travis laduke (Guest)
on 2006-04-20 18:16
(Received via mailing list)
i have this model:

class LineItem < ActiveRecord::Base
   belongs_to :quote
end

in the console:
 >>l = LineItem.create
ActiveRecord::StatementInvalid: 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 line_items (`qty`, `quote_id`, `price`, `lead_time`,
`part_number`) VALUES(, , , , )

why is it doing that? all my other models that belong_to something
work.
6e03895e5abb46f3daf4aafad3b98d5c?d=identicon&s=25 Randal Santia (Guest)
on 2006-04-20 18:22
(Received via mailing list)
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
D6ae681606a23d4d66fc4ab50a15137f?d=identicon&s=25 Lori Olson (lori)
on 2006-04-20 18:27
travis laduke wrote:
> i have this model:
>
> class LineItem < ActiveRecord::Base
>    belongs_to :quote
> end
>
> in the console:
>  >>l = LineItem.create
> ActiveRecord::StatementInvalid: 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 line_items (`qty`, `quote_id`, `price`, `lead_time`,
> `part_number`) VALUES(, , , , )
>
> why is it doing that? all my other models that belong_to something
> work.

http://api.rubyonrails.com/classes/ActiveRecord/As...

With such an association, you need to have an instance of a Quote object
to properly create a LineItem.

some_quote = Quote.find(some_id)
some_quote.line_items.create
E838033880a1e55e90f817f5b24a960b?d=identicon&s=25 travis laduke (Guest)
on 2006-04-20 19:08
(Received via mailing list)
>> q = Quote.find :first
=> #<Quote:0x257af14 @attributes={"status"=>"quoted",
"created_on"=>"2006-04-19 21:52:40", "follow_up_on"=>"2006-04-26
21:52:40", "updated_on"=>"2006-04-19 22:30:23", "id"=>"6",
"rep"=>"travis", "referred_by"=>"mectronic", "person_id"=>"4"}>
 >> q.line_items.create
ActiveRecord::StatementInvalid: 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 line_items (`qty`, `quote_id`, `price`, `lead_time`,
`part_number`) VALUES(#<Quote:0x256c7fc>, #<Quote:0x256aba0>, #<Quote:
0x256aba0>, #<Quote:0x256aba0>, #<Quote:0x256aba0>)


strange?
27c170f482104299af279902be0a9c26?d=identicon&s=25 Trevor Squires (Guest)
on 2006-04-20 19:08
(Received via mailing list)
Hey,

quote() is a method in ActiveRecord, perhaps that's the source of
your problem?

Regards,
Trevor
--
Trevor Squires
http://somethinglearned.com
E838033880a1e55e90f817f5b24a960b?d=identicon&s=25 travis laduke (Guest)
on 2006-08-03 14:22
(Received via mailing list)
doh!
now how would I go about migrating to a different model and table name?
This topic is locked and can not be replied to.