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.
You aren''t submitting any data into the database... hence "VALUES(, , , , )" . How are you submitting the data? Randal Signature Randal Santia Randal Santia 2 3 2005-12-15T19:39:00Z 2005-12-15T19:39:00Z 1 36 209 1 1 244 11.6408 false false false MicrosoftInternetExplorer4 w:LatentStyles> Randal Santia B2B Logic.net Website: http://www.b2blogic.net Email: randal-UNWnRcPzgprk1uMJSBkQmQ@public.gmane.org Phone: 905-829-9777 Toll Free: 888-945-5576 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._______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
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/Associations/ClassMethods.html 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 -- Posted via http://www.ruby-forum.com/.
Hey, quote() is a method in ActiveRecord, perhaps that''s the source of your problem? Regards, Trevor -- Trevor Squires http://somethinglearned.com On 20-Apr-06, at 9:14 AM, 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._______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
>> 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? On Apr 20, 2006, at 9:27 AM, Lori Olson wrote:> 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/Associations/ > ClassMethods.html > > 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 > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
doh! now how would I go about migrating to a different model and table name? On Apr 20, 2006, at 9:35 AM, Trevor Squires wrote:> Hey, > > quote() is a method in ActiveRecord, perhaps that''s the source of > your problem? > > Regards, > Trevor > -- > Trevor Squires > http://somethinglearned.com > > > > On 20-Apr-06, at 9:14 AM, 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._______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails