When I looked it up online, it said that the cause was a mismatch between the file name and the class name, but the file name is timelists_controller.rb
and the code matches the class name as follows:Please tell me how to resolve it.
class TimelistsController<ApplicationController
before_action —require_user_logged_in
def index
@timelists=Timelist.all
end
def create
@timelist=Timelist.new(time_params)
[email protected]
flash.now [:success] = "Posted."
render "toppages/index"
else
flash.now [:danger] = "Post failed."
render "toppages/index"
end
end
def destroy
@timelist=Timelist.find (params[:id])
@timelist.destroy
flash.now [:success] = "Your behavior has been logged."
render "times.index"
end
def time_params
param.require(:timemanagement).permit(:content)
end
end
The method in the TimelistsController
class references Timelist
, but because it is not defined anywhere, it is uninitialized constant
.
If Timelist
is defined under the TimelistsController
or is defined at the top level, no error occurs.
© 2024 OneMinuteCode. All rights reserved.