Co2 Co2 - 1 year ago 28
Ruby Question

ROR: Routes issue - Survey gem

The Survey gem is not creating the routes on my Rails app so I am wondering what to put in the routes.rb file?

I ran

rails generate survey:install

then ran

rails generate survey routes namespace:survey

and does not work.

I'm using Rails 4.2.1

The controllers are at controllers/survey/attempts_controller.rb and controllers/survey/surveys_controller.rb

The views are at survey/attempts/ and survey/surveys/

How should I put in the routes for these? Thanks.


Its okay if it didn't add routes to your routes.rb file. You can add it yourself. And since you have it namespaced within Survey for your controllers you have to namespace in your routes file too.

namespace :survey do
  resources :surveys
  resources :attempts
  get 'survey_details' => 'surveys#get_details' #this request will be handled by get_details method of SurveysController

Since it uses basic Create Read Update Delete in its controller, resources :surveys will take care of these. For any additional routes you want to define for your controllers make sure to put them inside the namespace block.