Help: association "sticks" in production mode

I have this self-referencial association that performs fine in dev
mode, but gets “stuck” in production mode. To be more specific, the
association is recalled from the first time an instance of the model
is loaded.
Here is the association’s declaration:

has_and_belongs_to_many :compeers,
:class_name => “Expression”,
:join_table => “expressions_compeers”,
:foreign_key => “id_a”,
:association_foreign_key => “id_b”,
:finder_sql => ‘SELECT e.* FROM expressions e,
expressions_compeers
c WHERE (e.id = c.id_a AND c.id_b = #{id}) OR (e.id = c.id_b AND
c.id_a = #{id})’,
:delete_sql => ‘DELETE FROM expressions_compeers WHERE (id_a =
#{id} AND id_b = #{record.id}) OR (id_a = #{record.id} AND id_b =
#{id})’

What’s different between the modes that could cause this discrepancy?
Does anybody have an idea?

Thanks
-Sebastian

sebastian wrote:

has_and_belongs_to_many :compeers,
:class_name => “Expression”,
:join_table => “expressions_compeers”,
:foreign_key => “id_a”,
:association_foreign_key => “id_b”,
:finder_sql => ‘SELECT e.* FROM expressions e,
expressions_compeers
c WHERE (e.id = c.id_a AND c.id_b = #{id}) OR (e.id = c.id_b AND
c.id_a = #{id})’,
:delete_sql => ‘DELETE FROM expressions_compeers WHERE (id_a =
#{id} AND id_b = #{record.id}) OR (id_a = #{record.id} AND id_b =
#{id})’

What’s different between the modes that could cause this discrepancy?
Does anybody have an idea?

Thanks
-Sebastian

Sebastian,

I believe that you have a db deadlock between expressions_compeers and
compeers. As a quick try, you can delete the :finder_sql and :delete_sql
conditions and try production mode again.

It may be too early in the morning, but I fail to see what the :find_sql
is buying you as that is already implied by the association you
expressed earlier in the method. My suggestion is to try to let
ActiveRecord handle the associations implicity as much as you can…

Which db vendor are you using? Which point in your code is it hanging?
During a find()?

On Feb 16, 3:11 pm, Ilan B. [email protected]
wrote:

Which db vendor are you using? Which point in your code is it hanging?
During a find()?


Posted viahttp://www.ruby-forum.com/.

Ilan,

You were right: the declaration was double-backed!
Everything works fine after removing the :finder_sql and :delete_sql
conditions.
Thanks a lot!
What threw me off was that it worked fine in dev mode…

Sebastian

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs