具有相同名称的类
我有一个用户模型:
class User < ActiveRecord::Base
end
该模型用于存储所有企业用户
然后我想在我的工作场所命名空间内有另一个用户模型:
class Workplace::User < ActiveRecord::Base
end
此类将用于我的用户在其工作场所中的用户
它不起作用并且当我想要迁移时,会出现以下错误消息:
Expected .../app/models/workplace/user.rb to define User
使用不同名称的模型没有这个问题,但我想使用相同的名称(对我来说更有意义......)
我该怎么办?谢谢!!!
I have a user model:
class User < ActiveRecord::Base
end
This model is used to store all the corporate users
Then I would like to have another user model inside my workplace namespace:
class Workplace::User < ActiveRecord::Base
end
This class would be used for the users of my users in their workplace
It doesn't work and rises following error message when I want to migrate:
Expected .../app/models/workplace/user.rb to define User
I don't have this issue with models using different names but I want to use the same name (makes more sense to me...)
How could I? Thanks!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您在命名空间中声明类时,rails 期望将 MVC 的文件放置在与命名空间同名的文件夹中。
尝试将它们放入
When you declare classes in a name space, rails expects the files for the MVC to be placed in a folder with the same name as the namespace.
Try placing them in