Creating Idea controller in Rails
Let’s fix the error we got in the previous page for uninitialized constant IdeasController
:
Routing Error
uninitialized constant IdeasController Did you mean? Ideastore
...
Fixing error for controller
Let’s try to understand error here.
The error says that our application doesn’t have constant (or class in this case) with name IdeasController
.
Let’s fix this by creating a controller with file name ideas_controller.rb
under app/controllers
folder.
# app/controller/ideas_controller.rb
class IdeasController < ApplicationController
end
Now, the above error should be fixed but we will different error.
Unknown action
The action 'show' could not be found for IdeasController
This error says that we don’t have action (or method in terms of programming) inside IdeasController
.
Updated the IdeasController
with method show
as:
# app/controller/ideas_controller.rb
class IdeasController < ApplicationController
def show
end
end
Template error
The error related to controller has gone and we are now getting following error which is related to view:
No template for interactive request
IdeasController#show is missing a template for request formats: text/html
NOTE!
...
Help me to improve BRG Trainings.