search for: get_enum_values

Displaying 1 result from an estimated 1 matches for "get_enum_values".

2006 Sep 09
1
Getting Valid ENUM Values in ActiveRecord
...I believe this will only work for MySQL). I would like to take it a step further and abstract this at the ActiveRecord::Base level. I have the following function, which works if placed in the individual class level (if there is a more efficient way to do it let me know): ===================== def get_enum_values(column_name) self.connection.columns(MyClass.table_name).each { |column| return column.sql_type.gsub("enum(''", "").gsub("'')", "").split("'',''") if column.name == column_name and column.sql_type[0...4] == &...