Belongs_to and table name quotes - DO NOT DO THIS



I’m a ROR newbie and have been pulling my hair out for a day trying to
figure out why I was getting an ActiveRecord::StatementInvalid when
trying to create a new record with a simple relationship. I have been
playing with ROR for a few days now and, ironically, this was the first
table that I tried to create associated records against.

Details: Table name: Quotes defined with has_many Activities. Upon
trying to create an activity (belongs_to :quotes) I would get an error
message indicating the SQL was invalid. This is a very simple
relationship and I couldn’t understand why I had downloaded samples with
belongs_to that worked but why I couldn’t get mine to work.

I found a post (gmane.comp.lang.ruby.rails:21139) with the same exact
problem but that went unresolved. I’m new to mailing lists and don’t
know how to reply directly to that post. He had this problem with the
same table name that I was using. That prompted me to change my table
name. Upon changing, everything works as expected.

Is there a way that this can get fixed? Anyone building a CRM
application will need a table called Quotes.

On a side note: I love this application - despite the troubles I had
with this table. I learned a lot while trying to troubleshoot this

Many thanks,



perhaps try using singular instead of plural

an activity belongs to a quote

class Activity < ActiveRecord::Base
belongs_to :quote

a quote has many activities

class Quote < ActiveRecord::Base
has_many :activities



Try belongs_to :quote, also take a look at the log file
(log/development.log) to see what sql was generated.


That was a typo on my part - it was belongs_to :quote

The problem is with the table name - Changing the table name solves the
issue all together.



Cuong T. removed_email_address@domain.invalid wrote:
Try belongs_to :quote, also take a look at the log file
(log/development.log) to see what sql was generated.