uday's blog

How to correct "rails generate" errors easily - Lesson learned 1

Yesterday I made a mistake and created controller with singular name instead of Plural name.

$rails generate controller Ticket

Then I realized my mistake and wanted to delete bunch of files that got created.

Easy way to delete all the files is as follows:

$rails destroy controller Ticket
$rails generate controller Tickets

It's worth mentioning the -p flag here ("p" for pretend).

Ruby on Rails - Controller

Controller

Controller takes model data from the database and then displays it on the view.

A controller is a Ruby class which inherits from ApplicationController and has methods just like any other class. When your application receives a request, the routing will determine which controller and action to run, then Rails creates an instance of that controller and runs the method with the same name as the action.