Ivan M. wrote:
I had the same problem.
I resolve all problems usind the “set_table_name” command ,that forge
the compiler to use the right model.
Thanks Ivan, but the table name isn’t really my problem, since the model
name actually matches the table name (‘Contact’ -> ‘contacts’).
Since there doesn’t seem to be a way to have AR deal with my ugly
composite-primary-key-table directly, I’m only looking for a way to
establish a connection within the class and execute raw queries over it.
connection_handler = ActiveRecord::Base.establish_connection(:foobar)
connection_handler.execute(“SELECT * FROM contacts WHERE a = ? and
b = ?”, foo, bar)
I see how to establish the connection, but I don’t understand how to
access it afterwards, since the above code doesn’t work (I know
establish_connection doesn’t return connection handlers, it’s just what
I would have done in PHP).
So, I’d still be thankful for any insights on how to deal with this (or
maybe even how to work around composite primary keys within AR?).