2

第一次使用关注点,只是在寻找一些建议。

我有一个名为 location.rb 的 Rails 模型,希望包含一个 AlbumDefineConcern,然后查询我们当前所在的模型类(在此类 Location 中)。

我有:

class Location < ActiveRecord::Base
  include AlbumDefineConcern
  ...

module AlbumDefineConcern
  extend ActiveSupport::Concern
  albums={}
  albums_locations = ["LocationHomeFeed","LocationProfile","LocationMobileMain"]
  albums[:locations]=albums_locations
  # I'd like it to output location or Location
  puts "here is class_name #{self.name}" 

我如何将“位置”作为班级名称?

#  puts "here is class_name #{self.parent.name}" => Object
4

1 回答 1

3
module AlbumDefineConcern
    extend ActiveSupport::Concern

    included do
        puts self
    end

end
于 2015-08-11T21:20:03.037 回答