Wow ok. So, the following:
Class Shape < ActiveRecord::Base attr_accessible :color_id belongs_to :color end Class Color < ActiveRecord::Base has_many :shapes end Now, in the console: sh = Shape.last ... sh.color_id 12 sh.color.name "red" ... c = Color.find(12) c.name = "blue" c.save! ... sh.color.name "blue" Oops! Now, every shape with shape.color_id =12 is now blue. You've changed a Color, but inadvertently changed a Shape as well. That's uncomfortable if not bad. But maybe it's just me. On May 18, 10:46 am, Marnen Laibow-Koser <li...@ruby-forum.com> wrote: > chewmanfoo wrote: > > what Scott was asking for originally was a way to enumerate options > > without having to reference their position in a list. if you use a > > database to create the list, then you necessarily have to reference > > their position get to them, but if you define the list with, say, a > > yml file, then position is irrelevant. So, you can alter the list at > > will without having to worry about the consequences for objects which > > reference the list - you just can't delete an item in the list. > > Nope, wrong. Primary key is not "position in a list". Please learn a > bit more about how SQL databases actually work. > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...@marnen.org > -- > Posted viahttp://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-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.