mercredi 15 juillet 2015

Routing error rails 3

I have a Rails 2.3.5 app with many controllers, models etc. which I'm trying to upgrade to Rails 3.2.1. I'm having some troubles with my routes. I tried to follow the Rails 3 new routing format but it doesn't seem to work. I'm getting three problems (which I guess all indicate one fundamental issue with my routing):

  1. In the root ('/') I'm getting the generic "Welcome abroad" Rails page. My routes (see below) have defined routing for root.
  2. For some controllers I get No route matches [GET] "/study" message. My route shows this route, but for some reason doesn't define the GET method.
  3. For some other controllers which do have defined GET in the routing I'm getting uninitialized constant StudyMapsController. I noticed that the controller's code is not executed.

Here's my config/routes.rb code:

Myapp::Application.routes.draw do    
  root :to => 'study#index'

  match 'login' => 'login', :protocol => 'https://'

  resources :study_maps do
    get :clone, :on => :member
  end

  # Route report create actions to the report controller
  match 'report/create', :as => 'report'

  match ':controller(/:action(/:id))(.:format)'
end

If I'm running rake routes I'm getting:

           root        /                                      study#index
          login        /login(.:format)                       login#login {:protocol=>"https://"}
clone_study_map GET    /study_maps/:id/clone(.:format)        study_maps#clone
     study_maps GET    /study_maps(.:format)                  study_maps#index
                POST   /study_maps(.:format)                  study_maps#create
  new_study_map GET    /study_maps/new(.:format)              study_maps#new
 edit_study_map GET    /study_maps/:id/edit(.:format)         study_maps#edit
      study_map GET    /study_maps/:id(.:format)              study_maps#show
                PUT    /study_maps/:id(.:format)              study_maps#update
                DELETE /study_maps/:id(.:format)              study_maps#destroy
         report        /report/create(.:format)               report#create
                       /:controller(/:action(/:id))(.:format) :controller#:action

Can someone advise on what I'm missing?

Aucun commentaire:

Enregistrer un commentaire