Remove association model in Rails

爷,独闯天下 提交于 2019-12-10 18:13:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!