To clarify, I was previously doing using a callback via before_create,
like so

      before_create :set_uuid
      def set_uuid
        self.id = UUIDTools::UUID.timestamp_create.to_s
      end

On Jul 8, 6:45 pm, Geoff Harcourt <[email protected]> wrote:
> I never knew what the proper practice was for this sort of thing. In
> scenarios where I had to ensure that a primary key was set to a number I
> specified, I always used a callback to modify the ID to match a facade
> attribute if it had been set.
>
> I'm sure that's wrong, but I could never figure out a more reliable way to
> do it.
>
> -Geoff
>
> On Fri, Jul 8, 2011 at 1:37 PM, Luis Correa d'Almeida 
> <[email protected]>wrote:
>
>
>
>
>
>
>
> > In ActiveRecord 3.1.0.rc4, setting the id manually no longer works -
> > the assignment seems to be ignored. Is this expected behavior? Seems
> > to break BC
>
> > create_table :posts, :id => false do |t|
> >    t.string :id, :limit => 36, :primary => true, :null => false
> >    t.string :title
> > end
>
> >  > @post = Post.new
> >  > @post.id = "abc123"
> >  > @post.id
> >   => nil
>
> >  > @post.save!
> >    => Fails because id is nil/null (obviously)
>
> > Thoughts?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Ruby on Rails: Core" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/rubyonrails-core?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to