Pete Campbell wrote in post #967747:
> Its a good suggestion but sadly the answer is no. There is another app
> that also accesses this data and so I *probably* can't change it.
>
> Is this behavior expected or not? It was a bit of a surprise to me.
>

A little unexpected... but the source makes it obvious what is 
happening.

module ActiveRecord
  module AttributeMethods
    module Write

      blah blah blah

      def write_attribute(attr_name, value)
        attr_name = attr_name.to_s
        attr_name = self.class.primary_key if attr_name == 'id'

Seems like it ought to check and see if
  set_primary_key = something other than "id"
is set in the model and behave accordingly (if "id" is not the model's 
primary key, then don't remap attr_name to self.class.primary_key).

Of course, I've just looked at this one small snippet of code, and there 
may be other places in the AR code base that use 'id' as a name alias 
for the primary key (whatever it is), so removing that bit of 
redirection might totally hose up AR.

-- 
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-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.

Reply via email to