Reputation: 1624
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
Upvotes: 1
Views: 285
Reputation: 21791
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.
Upvotes: 0
Reputation: 3224
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
Upvotes: 4
Reputation: 264
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
.
Upvotes: 1