Reputation: 3802
This line in my stands_controller.rb file:
@stand_items = Stand_Item.where("stand_id = " + (params[:id]).to_s)
causes the error:
uninitialized constant StandsController::Stand_Item
But, I have a file named: stand_items_controller.rb with the contents:
class StandItemsController < ApplicationController
end
I have tried many constant names such as StandItem, Standitem, Stand_item and plurals of all those but no success.
What is the correct constant name? Is there some place where rails stores it?
I have this same concept working elsewhere in the code: I have the line:
@mark_count = Markstand.where("stand_id = " + (params[:id]).to_s)
directly above the line causing the error, and it gives no error. Markstand is the constant name for the file markstands_controller.rb which has the contents:
class MarkstandsController < ApplicationController
end
EDIT 1 This is how I made the controller:
bin/rails generate controller stand_items
Upvotes: 0
Views: 91
Reputation: 9620
You've generated a controller but you're trying to use a model from within that controller. You need to generate a model for StandItem and then use that from the controller.
bin/rails generate model stand_item ...
See the documentation for the parameters you can pass to setup your model.
Upvotes: 1