Reputation: 1545
Suppose we create a new controller with an action to perform an operation and rendering a view.We add a route via plugin file and I checked the route found via rake routes as
register_vip_section GET /register/vip_section(.:format) vip_section#index
The controller looks like:
class VipSectionController < ApplicationController
def index ... end
end
but when I tries to make a get call to the same as:
http://localhost:3000/register/vip_section
It doesn't work.It is raising :
Started GET "/404-body?_=1489209463400" for 127.0.0.1 at 2017-03-11 10:47:46 +0530
I, [2017-03-11T10:47:47.051542 #19641] INFO -- : Processing by ExceptionsController#not_found_body as HTML
I, [2017-03-11T10:47:47.054589 #19641] INFO -- : Parameters: {"_"=>"1489209463400"}
D, [2017-03-11T10:47:47.062975 #19641] DEBUG -- : User Load (3.2ms) SELECT "users"
Upvotes: 0
Views: 219
Reputation: 368
The formatting of your route from rake routes
suggests that it will look for a RegisterController
with a vip_section
action when you make the call: http://localhost:3000/register/vip_section
-- or --
For the controller you have described you would need a routes similar to this in your routes:
resources :register do
get 'vip_section', on: :collection
end
EDIT:
As I previously said, for the path you mention your controller should be called RegisterController
and have an action called vip_section
as follows
class RegisterController < ApplicationController
def vip_section
end
end
In this route path: http://localhost:3000/register/vip_section
the first part of the path is for the controller
and the second section of the path is for the action
method
EDIT2: I see you have added the vip_section#index
to the path you mentioned. It is convention to name controllers as a plural. Please try naming your controller VipSectionsController
Upvotes: 0