rails 模型的别名 [英] Alias for rails model

查看:39
本文介绍了rails 模型的别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在其中一个 rails 应用程序中的模型名称是 OrganizationUser,有什么方法可以为此模型创建别名为 OU 或 OrgUser,以便我可以在 rails 控制台中使用..

My model name in one of rails app is OrganizationUser and is there any way to create alias name for this model as OU or OrgUser so that I can use in rails console..

推荐答案

如果 kishie 的回答不适合您,您可以创建另一个继承自 OrganizationUser 的模型:

If kishie's answer does not suit you you could create another model that inherits from OrganizationUser:

class OU < OrganizationUser
end

class OrgUser < OrganizationUser
end

这篇关于rails 模型的别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆