Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个模型“位置”,其中有许多“课程”
如果我销毁一个位置,我希望拒绝销毁请求,除非该位置与任何课程之间没有关系。我认为有一些非常简洁的方法可以做到这一点,但我找不到任何东西。
Soo ...启用此类功能的最优雅/简单/简洁的方式是什么?
在位置...
before_destroy do |l| return false unless l.courses.nil? end