How to convert attribute name to string?
- by Acidburn2k
Lets say we have some basic AR model.
class User < ActiveRecord::Base
attr_accessible :firstname, :lastname, :email
end
...
some_helper_method(attrib)
...
def
Now I would like to pass someuser.firstname to helper and I would like to get both the value and the attribute name, for example:
some_helper_method(someuser.firstname)
> "firstname: Joe"
some_helper_method(someuser.lastname)
> "lastname: Doe"