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 <luis...@gmail.com>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 rubyonrails-core@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-core+unsubscr...@googlegroups.com.
> 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 rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-core+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to