0

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"
Jaswinder
  • 1,455
  • 14
  • 27

1 Answers1

0

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

Dawcars
  • 378
  • 2
  • 8
  • I have mention the controller path in the second line. Please check this register_vip_section GET /register/vip_section(.:format) vip_section#index – Jaswinder Mar 11 '17 at 12:32
  • Yes, as I mentioned for that path your controller should be called `RegisterController` not a `VipSectionController` and your action should be called `vip_section` not `index` – Dawcars Mar 11 '17 at 12:45
  • Hey Dawcars. You don't understand. As for the above rake routes its :get '/register/vip_section' => 'vip_section#index' – Jaswinder Mar 11 '17 at 13:00
  • Apologies, I missed the `vip_section#index` part. Perhaps you need to name your controller as a plural. I think it should be called `VipSectionsController` – Dawcars Mar 11 '17 at 13:15