Where's the list of valid attributes / methods for column ob


#1

I’m trying to figure out what the valid attributes are on a column
object.
The Rails scaffolding generates a list view that uses column.column_name
for
example. ActiveRecord::Base#columns says it returns “an array of column
objects for the table associated with this class”. But I can’t find a
list
of the attributes of / methods on a column object anywhere.

Any help would be very much appreciated.

Thanks,
Bill


#2

Hello,

On 2 Mar 2007, at 05:07, Bill W. wrote:

I’m trying to figure out what the valid attributes are on a column
object.
The Rails scaffolding generates a list view that uses
column.column_name for
example. ActiveRecord::Base#columns says it returns “an array of
column
objects for the table associated with this class”. But I can’t
find a list
of the attributes of / methods on a column object anywhere.

Try using script/console:

Let’s say that you have a User model.

User.columns.first.methods
=> [“to_a”, “respond_to?”, “returning”, “daemonize”, “type”, “limit”,
“protected_methods”, “human_name”, “silence_stream”, “eql?”,
“number?”, “instance_variable_set”, “precision”, “is_a?”, “taguri”,
“hash”, “to_s”, “send”, “dclone”, “remove_subclasses_of”, “ri”,
“pretty_print_cycle”, “primary”, “default”, “with_options”,
“taguri=”, “silence_warnings”, “pretty_print_inspect”, “class”,
“tainted?”, “private_methods”, “primary=”, “send”, “to_yaml”,
“to_yaml_properties”, “untaint”, “scale”,
“extend_with_included_modules_from”, “id”, “instance_eval”,
“inspect”, “require_library_or_gem”, “pretty_print”, “klass”,
“type_cast_code”, “clone”, “text?”, “public_methods”, “b64encode”,
“extended_by”, “extend”, “require_gem”, “freeze”, “suppress”,
“display”, “encode64”, “instance_values”, “po”, “type_cast”, “`”,
id”, “pretty_print_instance_variables”, “methods”, “==”,
“method”, “sql_type”, “decode64”, “gem”, “===”, “to_json”,
“subclasses_of”, “dup”, “nil?”, “enable_warnings”,
“instance_variables”, “copy_instance_variables_from”, “instance_of?”,
“load”, “name”, “poc”, “to_param”, “instance_exec”, “=~”,
“object_id”, “singleton_methods”, “decode_b”, “null”, “unloadable”,
“taint”, “equal?”, “silence_stderr”, “blank?”,
“instance_variable_get”, “frozen?”, “kind_of?”, “require”,
“to_yaml_style”]

Regards,
Andy S.


#3

Also see:

http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/Column.html

~ j.