Doug wrote:
> A lot has been posted about validation issues with associations,
> however, I don't see this issue addressed specifically.
> 
> ex:
> class Foo
>   has_one :schedule, :dependent => :destroy
>   validates_presence_of :schedule
> 
> class Schedule
>   belongs_to :foo
>   validates_presence_of :foo_id
> 
> this creates a circular dependency that breaks test frameworks like
> pickle and machinist.
> At first I was surprised a little that you can contsruct objects with
> this constraint
> ...you can of course with "new" and "save"
> ...though I it sounds like the destroy will cause a problem.
> http://mohammed.morsi.org/blog/taxonomy/term/29
> 
> is there a workaround for tests?
> 
> or is this a bad idea from the start?

It's a bad idea from the start.  Get rid of the validation on the 
has_one side.

> 
> Nevertheless, It seems to me that while a noble goal -- to validate
> both sides of the assoication.
> How else to do it?

Don't.  It's unnecessary.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
> thanks?

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