我有两个模型Plan和Student::Plan. 当调用Student::Plan.create!我的seeds.rb 文件时,我得到了一个Plan对象。似乎rails被命名空间或其他东西弄糊涂了。任何不涉及重命名课程的想法?
文件结构
models
plan.rb
student
plan.rb
表
- 计划
- 学生计划
更新
这在测试 w/ 时变得更加奇怪rails c。如果你Student::Plan.create! 先打电话,那么你会得到预期的对象。如果您改为调用Plan.create!,那么Student::Plan.create!您将返回一个Plan对象,而不是您实际期望的对象。
作品
Student::Plan.create # <Student::Plan...>
不工作
Plan.create # <Plan...>
Student::Plan.create # <Plan...>