Hi!
I''m new to Rails, but I''ll try to help.
Maybe you could use the before_destroy callback:
http://guides.rubyonrails.org/active_record_validations_callbacks.html#destroying-an-object
Best Regards,
Everaldo
On Tue, Jul 26, 2011 at 10:35 AM, Piter Fcbk
<piter.fcbk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Given the models Country, State, City and Person as follows.
>
> class Country < ActiveRecord::Base
> has_many :states
> end
>
> class State < ActiveRecord::Base
> belongs_to :country
> has_many :cities
> end
>
> class City < ActiveRecord::Base
> belongs_to :state
> has_many :people
> end
>
> class Person < ActiveRecord::Base
> belongs_to :city
> end
>
> Is there any way that doesn''t allow to delete a country if it has
states?
> (will do the same for states and cities, cities and persons).
> Didn''t saw nothing like that in the dependent option.
>
> Thanks in advance.
>
> --
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.