Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- model.columns.each do |val|
- # i got now:
- # val == key
- # model[val] == value
- myPrint(val , model[val])
- end
- class Sequel::Model
- # helper method to get {:keys=>:accessors}
- def self.assoc_list
- res = Hash.new
- association_reflections.each do |k,v|
- res[v[:key]] = k
- end
- return res
- end
- end
- class Unittype < Sequel::Model(:unittypes)
- end
- class Unit < Sequel::Model(:units)
- many_to_one :unittype
- end
- #trying to print Units
- Unit.all.each do | u |
- Unit.columns.each do | col |
- if Unit.assoc_list.key?(col)
- key = Unit.assoc_list[col]
- # ok, now i got key == :unittype
- # and want to get value = Unit.key.name (Unit.unittype.name)
- value = ???
- MyPrint(key,value)
- else
- # key, value
- MyPrint(col,u[col])
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement