I generated a controller called Search. later I built a model called search as well. When i try to make a search i get an error that says there is no controller called searches, so it looks like it the model interacts with the plural of itself by default. how do i change this behaviour
3 Answers
Sounds like you are quite new to rails. The best advice here is almost certainly "don't" Rails uses a lot of conventions to avoid having to configure everything, and this is one of them. So I would recommend changing the name of your controller rather than trying to make rails do something out of the ordinary
for more detail see this stackoverflow question

- 1
- 1

- 3,204
- 1
- 21
- 23
-
Excellent advice. Convention over configuration. – Fred Oct 13 '11 at 20:09
Just rename the controller class from 'SearchController' to 'SearchesController'. Also rename the file in apps/controllers
to from search_controller.rb
to searches_controller.rb
.

- 264
- 1
- 4
When you have generated controller and model separately, you also generated additional files like test files, views and so on. So potentially you will have big headache on this.
I would recommend to use rails destroy
command in these steps:
Commit your current project (later you can recover your content from it)
Run this commands:
rails destroy model Search
rails destroy controller Search
Restore your controller and model from previous commit.

- 21,401
- 12
- 79
- 130