除去在Rails的关联模型 [英] Remove association model in Rails
本文介绍了除去在Rails的关联模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道,如果它possilbe删除关联的轨道。
Hi i would like to know if its possilbe to remove an association in rails.
嗯,我有类似这样:
class Home < ActiveRecord::Base
include settings
end
在settings.rb我有类似于这样
On settings.rb i have something similar to this
module Settings
attr_reader :person
attr_reader :address
def self.included(base)
base.belongs_to :city
base.belongs_to :entity
[...]
end
[...]
end
在家庭类在我的特殊情况下的城市模型关联没有任何意义。我必须找到一种方法将其删除,以保持我的code干燥。
On Home class the city model association on my particular case don't make sense. And i have to find a way to remove it to maintain my code DRY.
感谢您!
注:投票前反馈给我下来,请
NOTE: Give me feedback before vote down please.
推荐答案
如果你只是不想方法,然后使用 remove_method
将其删除。
If you just don't want the methods then use remove_method
to remove them.
这篇关于除去在Rails的关联模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文