This answer says you can do object.attribute_names to get a list of attribute names for a model instance.
But is there any way to get a list of all its accessible attribute names?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
accessible_attributes.You have to provide a role, because different roles can have different accessible attributes.
If you want to have the attributes from a model instance you can use this code: