How can you discover accessible attribute names from a model instance?

我们两清 提交于 2019-12-08 14:06:30

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:

@my_model.class.accessible_attributes(:admin) # Returns array of symbols
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!