首次使用问题而只是寻求一些建议。
我有一个名为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}"
我如何获得&#34; location&#34;作为班级名称?
# puts "here is class_name #{self.parent.name}" => Object
答案 0 :(得分:2)
module AlbumDefineConcern
extend ActiveSupport::Concern
included do
puts self
end
end