问题
Hi i would like to know if its possilbe to remove an association in rails.
Well, i have something similar to this:
class Home < ActiveRecord::Base
include settings
end
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
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.
Thank you!
NOTE: Give me feedback before vote down please.
回答1:
If you just don't want the methods then use remove_method
to remove them.
来源:https://stackoverflow.com/questions/8647564/remove-association-model-in-rails