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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 > -SebastianSebastian, 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()? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 16, 3:11 pm, Ilan Berci <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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()? > > -- > 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---