I am new to Ruby on Rails and have some problems.
For the development I use RubyMine IDE, I manage to create models, controllers and views, but I have problems with the routing. By default, routes.rb
file contains only this method Apis::Application.routes.draw do
with an empty body.
For example, I create a controller TestController
, then the index
method and in routes.rb
I add this instruction resources :test
. So far, it works fine. But if I add another method, let's say method1
(and the view) I can't reach it in a browser http://localhost:3000/test/method1
.
What else should I add in routes.rb
file?
Is there any way to make the routing automatically from the IDE, with less editing the routes file?
resources :test
is a resourceful route which provides a mapping between HTTP verbs and URLs to controller actions. By convention, each action also maps to particular CRUD operations in a database
you can uncomment in your routes to enable the controller action mapping.
match ':controller(/:action(/:id(.:format)))'
or use -
match "/test/method1" => "test#method1"
Detailed routes info @ http://guides.rubyonrails.org/routing.html