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.
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
doh!
now how would I go about migrating to a different model and table name?
Hey,
quote() is a method in ActiveRecord, perhaps that’s the source of
your problem?
Regards,
Trevor
Trevor S.
http://somethinglearned.com