Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Austin Klenk
4,399 PointsName Error - Ruby on Rails
5 # GET /workorders.json
6 def index
7 @workorders = Workorder.all
8 end
9
10 # GET /workorders/1
uninitialized constant WorkordersController::Workorder app/controllers/workorders_controller.rb:7:in `index'
5 Answers
Chris McKnight
Courses Plus Student 11,045 PointsThe Rails autoloader is failing to load your Workorder model since it's defined in customer.rb. It is recommended to move your Workorder class into a separate file. Currently, you have it defined in customer.rb.
# app/models/workorder.rb
class Workorder < ActiveRecord::Base
belongs_to :customer
end
If you want to keep Workorder in customer.rb, take a look at how the Rails autoloading mechanism works and configure your environment appropriately.
John Steer-Fowler
Courses Plus Student 11,734 PointsHey Austin,
The error you have encountered is usually found when you are trying to refer to a class or module that does not currently exist or has not been defined yet.
Hope this helps
Austin Klenk
4,399 Pointsif i upload it to github could you look at it, i have a good month of work in the app ;(
John Steer-Fowler
Courses Plus Student 11,734 PointsSure, but you should be able to fix that error from the error message.
Austin Klenk
4,399 PointsIve tried, i about deleted the whole application and started over again. but here is the github url
git@github.com:mastertechrv/MTRV_CLOUD.git https://github.com/mastertechrv/MTRV_CLOUD
John Steer-Fowler
Courses Plus Student 11,734 PointsHey Austin,
Is it because you have used the plural of workorder in your controller?
Try:
def index
@workorder = Workorder.all
end
Let me know how it goes.
Austin Klenk
4,399 Pointschanged it and still getting the same error
John Steer-Fowler
Courses Plus Student 11,734 PointsI'm stumped then I'm afraid.
Hopefully someone else will be able to have an input on your question.