Topic: Rail Routes after upgrade from 2.3.5 to 3.0.10
I'm close to getting my application up and running after upgrading from 2.3.5 to 3.0.10, but I keep getting an error message saying my login route does not exist. Below is the login controller code & the route code:
Login Controller:
class LoginController < ApplicationController
layout "trinity_price_comparison"
before_filter :allowed_admin, :only => [:switch_admin]
def login
session[:user_id] = nil
if request.post?
user = User.authenticate(params[:username], params[:password])
if user
if !user.active
flash.now[:notice] = "Your account has been disabled, please contact your administrator."
else
session[:user_id] = user.id
session[:user] = user
session[:admin_flag] = false
uri = session[:original_uri]
session[:original_uri] = nil
if uri != nil
redirect_to(uri || {:controller => "items", :action => "search"})
else
redirect_to :controller => "items", :action => "search"
end
end
else
flash.now[:notice] = "Invalid username/password combination"
end
end
end
def logout
session[:user_id] = nil
flash[:notice] = "Logged out"
redirect_to :controller => "items", :action => "search"
end
def switch_admin
session[:admin_flag] = !session[:admin_flag]
redirect_to :controller => "items", :action => "search"
end
endHere are the routes:
Apex::Application.routes.draw do
resources :cross_references
resources :uom_conversions
resources :items
match 'delete_old_data/delete_data' => "items#delete_data"
match 'delete_old_data' => "items#delete_old_data"
match 'pricelist_import' => "items#pricelist_import"
match 'pricelist_import/match_pricelist_columns' => "items#match_pricelist_columns"
match 'commit_pricelist' => "items#commit_pricelist"
match 'pricelist_tool' => "items#pricelist_tool"
match 'cross_reference_import' => "items#cross_reference_import"
match 'commit_cross_references' => "items#commit_cross_references"
match 'import_file/commit_import' => "items#commit_import"
match 'import_file' => "items#import_file"
match 'import_file/match_columns' => "items#match_columns"
match 'set_default_matches' => "items#set_default_matches"
match 'save_default_matches' => "items#save_default_matches"
match 'search' => "items#search"
match 'search/import_search_file' => "items#import_search_file"
match 'search/import_search_file/pick_search_column' => "items#pick_search_column"
match 'items/create_uom' => "items#create_uom"
match 'items/remove_uom/:uom_id' => "items#remove_uom"
match 'items/show_cross_references/:id' => "items#show_cross_references"
resources :vendors
resources :manufacturers
resources :categories
resources :sub_categories
resources :hospitals
resources :agreements
resources :users
match 'users/change_password' => "users#change_password"
match 'users/update_password'=> "users#update_password"
match 'logout' => 'login#logout', :as => :logout
match 'switch_admin' => 'login#switch_admin', :as => :logout
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Sample resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Sample resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Sample resource route with more complex sub-resources
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', :on => :collection
# end
# end
# Sample resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
# root :to => 'welcome#index'
root :to => 'items#search'
# See how all your routes lay out with "rake routes"
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id))(.:format)'
match ':controller/:action/:id'
match ':controller/:action/:id.:format'
end