Ramy
Ramy

Reputation: 21261

Issue using rails generator controller

I'm completely new to rails and mostly new to web development in general. i'm trying to create a whole new tab within a page on our website. I'm trying to emulate as much as possible a tab that's already built out in our application. I noticed that there was a controller and a view associated with the tab i'm trying to emulate so I used the rails generator to create a controller for the tab (which will contain a report) i'm trying to build. So I ran generator through RubyMine (tools -> Run Rails Generator...), gave it the name i wanted to use, RejectedOffersReportController, and used show and initialize as the two actions. Incidentally, the tab i'm trying to emulate has both of those methods in the controller but only has a view for show - i'm not sure what that means exactly.

In any case, back to the matter at hand - first of all, when I go to the page where i expect the tab to be, the tab isn't there. Secondly, when I try to manually navigate (i.e. put the address in manually - localhost:3000/admin/rejected_offers_report) I get the following message in my browser:

Routing Error

uninitialized constant Admin::RejectedOffersReportsController

the bizarre part is that RejectedOffersReportsController is not anywhere to be found in my project when I do a project-wide search in the RubyMine IDE. (Notice the plural form of reports which is not the name i used in the controller generator).

Any and all help is appreciated.

UPDATE: ok, so i get why initialize isn't necessary.

Upvotes: 2

Views: 206

Answers (1)

Chuck Callebs
Chuck Callebs

Reputation: 16441

Controllers default to the pluralized form of the class name. Just rename your controller file/class to RejectedOffersReportsController.

It's easier just to go along with the Rails conventions unless you have a good reason not to.

Upvotes: 2

Related Questions