Friday, March 25, 2011

[Rails] Re: shared primary key (using the primary key as a foreign key for has_one association)

Kendall, thank's for your suggestion, it really made "id" and
"person_id" equivalent for instructors and stopped the described above
weird (and fun) behavior.

Also,

p=Person.create
m=p.create_member
i=p.create_instructor

work as expected now with setting identical values for p.id, m.id,
m.person_id, i.id, and i.person_id.

When an instructor with the value of id equal to p.id already exists,
i=p.create_instructor
triggers
ActiveRecord::StatementInvalid: SQLite3::ConstraintException: PRIMARY
KEY must be unique: ...

which is a desired behavior.

I will keep testing, and if i do not encounter something extremely
weird, i may stick to this...

Thank you.

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate