In the view you can check if value is not nil but what would be the easiest way to check if column is present?
I did the following.
test
def test_has_column?
person = Person.find(:first)
assert person.has_column? "name"
assert !person.has_column? "some_uknown_column_name"
end
Code
added to app/controllers/application.rb
module ActiveRecord
class Base
def has_column?(column_name)
attributes.has_key? column_name
end
end
end