Greg Willits wrote in post #1109539: > Seems to me acts_as_list has a bug -- I have data where the row id is a > random alphaNumeric, not a simple integer. Using acts_as_list with a > scope of a related model id, acts_as_list crashes the app due to a > faulty query in MySQL something like this: > > class LineItem < ActiveRecord::Base > belongs_to :order > acts_as_list :scope => :order_id > end > > Unknown column 'UXPzIdeIuIFkz6n' in 'where clause': UPDATE `line_items` > SET position = (position - 1) WHERE (order_id = UXPzIdeIuIFkz6n AND > position > 5) > > I've been trying several ways to force substition to generate those > needed quotes myself, but so far no luck. > > Anyone battle & solve this? Thx.
For future reference this is one of those times that fighting Rails conventions makes your life more difficult as a Rails developer. Rails wants it simple incrementing integer primary keys. If you can accommodate that wish then life for you as a developer gets simpler. If you want a key that is non-numeric, create a separate column and put a unique constraint on it, but let Rails have its standard simple integer key for use in creating associations. If you really want to fix the problem the I suggest you fork the acts_as_list repository and fix the bug there. My guess is that the author of acts_as_list assumed the Rails conventions and never tested the scenario you've presented here. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b6887584ae6c795286fd8a9f9b14f697%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.

