0
如何从Ruby模型获取属于某个类的所有属性或column_names(即在数据库中具有某种列类型)?从属于某个类的Ruby模型获取字段
E.g.:
-Get all column_names belonging to class ActiveSupport::TimeWithZone from following Model having fields:
:id
:order_id String
:slot_id Integer
:delivery_date TimeWithZone
:packed_date TimeWithZone
:created_at TimeWithZone
:updated_at TimeWithZone
-Output:
['created_at','updated_at','delivery_date','packed_date']
的[最快的/一个班轮可能的方式重复在Ruby中列出attr \ _accessors?](http://stackoverflow.com/questions/2487333/fastest-one-liner-way-to-list-attr-accessors-in-ruby) –
我不认为这是一个正确的副本提名的examplar:这个问题问如何找到所有使用attr_accessor定义的访问器方法。此问题询问如何查找映射到特定类型列的列的所有访问器方法。 –
我做了一个编辑,希望能让问题更清楚。如果我错了,请回滚我的编辑。 –