Post.author_id or ? Rails bug?

Hi all!

I have just found something very strange.

Let’s imagine that I have posts that belong to an author.

If I do the following (the order doesn’t matter): = Author.find(3)
apost.author_id = 2

I get a post that has both an :author_id => 2 attribute, and an
associated Author with id 3.

Then,, and the author_id in the DB is 3.

I think that this is a little bit confusing… Is there something useful
in allowing to have both an author_id and an author that do not match?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs