mindpin / kc_courses

MIT License
0 stars 6 forks source link

修改 User关联方法定义方式 #3

Closed fushang318 closed 8 years ago

fushang318 commented 8 years ago

建议用如下形式定义User关联方法

module KcCourses
  class Engine < ::Rails::Engine
    config.to_prepare do
      User.class_eval do
        has_many :courses, class_name: 'KcCourses::Course'
        has_many :chapters, class_name: 'KcCourses::Chapter'
        has_many :wares, class_name: 'KcCourses::Ware'
        has_many :joins, class_name: 'KcCourses::Join'
      end
    end

  end
end