ActiveRecord::Reflections将个人元数据添加到Reflection
嗨,我有下面的型号ActiveRecord::Reflections将个人元数据添加到Reflection,activerecord,metadata,activemodel,Activerecord,Metadata,Activemodel,嗨,我有下面的型号 class Tale < ActiveRecord::Base #TODO model should be created automatically based on the structure attr_accessor :sex, :family, :me after_initialize do @sex = nil @family = [] @me = [] end before_create do self.joined = false true e
class Tale < ActiveRecord::Base #TODO model should be created automatically based on the structure
attr_accessor :sex, :family, :me
after_initialize do
@sex = nil
@family = []
@me = []
end
before_create do
self.joined = false
true
end
has_many :tale_culture_joins
has_many :tale_purpose_joins
has_many :tale_book_joins
has_many :tale_keyword_joins
has_many :tale_character_joins
has_many :tale_moral_joins
has_many :tale_event_joins
#TODO Grouping models with a unique single identifier that can be searched for as tag. Like these are associations for searching
#TODO need to fix so that on query only uniq results are returned ... can be added @runtime
has_many :cultures, through: :tale_culture_joins, dependent: :destroy
has_many :purposes, through: :tale_purpose_joins, dependent: :destroy
has_many :books, through: :tale_book_joins, dependent: :destroy
has_many :keywords, through: :tale_keyword_joins, dependent: :destroy
has_many :characters, through: :tale_character_joins, dependent: :destroy
has_many :morals, through: :tale_moral_joins, dependent: :destroy
has_many :values, through: :morals
has_many :events, through: :tale_event_joins, dependent: :destroy
has_many :hyperlinks
has_many :content_types, through: :hyperlinks
end
应根据结构自动创建TODO模型
属性访问器:性、家庭、我
在你初始化之后做什么
@性别=零
@家庭=[]
@me=[]
结束
在你创建之前
self.joined=false
真的
结束
有很多:故事、文化
有很多:故事、目的
有很多:故事书
有很多:故事关键字加入
有很多:故事、人物
有很多:故事、道德
有很多:故事、事件
#TODO使用可作为标记搜索的唯一单个标识符对模型进行分组。这些都是用于搜索的关联
#TODO需要修复,以便在查询时只返回uniq结果。。。可以在运行时添加
有很多:文化,通过::故事(文化)加入,依赖::摧毁
有很多:目的,通过::故事?目的?连接,依赖::销毁
有很多:书,通过::故事,书加入,依赖::破坏
有很多:关键字,通过::tale\u关键字\u连接,依赖::销毁
有很多:字符,通过::故事\字符连接,依赖::销毁
有很多:道德,通过故事,道德,依赖,毁灭
有很多:价值观,通过道德
有很多:事件,通过::故事事件,依赖::销毁
有很多:超链接
有很多:内容类型,通过::超链接
结束
一些反射用于从表单获取和发布数据。
可以看出,价值观通过道德与故事有关。但是,我不会将其存储在一个值联接表中
我执行数据输入和搜索功能。要仅为搜索定义某些反射。如何将标记|元数据|键添加到反射中,以便稍后检查
例如,在has_many:values上,我想添加选项:searchable。。这对我来说,当我构建搜索界面时,我想查询那些作为标记可搜索的反射