I have two models Plan and Student::Plan. When calling Student::Plan.create! in my seeds.rb file I get back a Plan object. It seems as though rails is getting confused by the namespacing or something. Any thoughts that don't involve renaming the class?
file structure
models
plan.rb
student
plan.rb
tables
- plans
- student_plans
Update
This gets even weirder when testing w/ rails c. If you call Student::Plan.create! first then you'll get the expected object back. If you instead call Plan.create! and then Student::Plan.create! you'll be back a Plan object instead of what you'd actually expect.
Works
Student::Plan.create # <Student::Plan...>
Doesn't Work
Plan.create # <Plan...>
Student::Plan.create # <Plan...>
Student::Plan?Student::Planinherit fromPlan? Are you referencingPlanwithin theStudentmodule beforeStudent::Planis properly loaded? Calling these bothPlanis trouble.Student::Planto lib. 2. placerequire 'student/plan'where you need to referenceStudent::Plan.models/student.rbto definemodule Studentsee: stackoverflow.com/questions/9712468/… and wondible.com/2011/12/23/…