Could not find anything specific for this problem (other search queries relate to forms, etc.). It was probably a simple oversight on my part. But what am I not seeing?
PURPOSE: I am simply trying to redirect a URL /loginto a URL /dashboardif a session exists.
EXPECTED RESULT: Challenge redirect_to dashboard_index_urlor redirect_to '/dashboard'should go tohttps://mydomain/dashboard
CURRENT RESULT: if I go to https://mydomainafter creating a session, it redirects me to https://mydomaindashboard, note the missing slash
FOLLOWING DECISIONS:
- Manually enter the URL https: // mydomain / dashboard after creating the session RESULT: so the correct route seems to exist
- Make a manual route
routes.rb, RESULT: The behavior is the same as the resourcerouting of a missing slash - Clear browser cache, use different browswers RESULT: all demonstrate the same behavior
Here is what I have (abbreviated to the relevant parts):
class LoginController < ApplicationController
def index
redirect_to dashboard_index_url if session[:user_id]
end
end
class DashboardController < ApplicationController
before_action :require_login
def index
end
end
resources :login
resources :dashboard
get 'dashboard' => "dashboard#index"
@Ryan Here is the current output for routes:
$ rake routes
Prefix Verb URI Pattern Controller#Action
login_index GET /login(.:format) login#index
POST /login(.:format) login#create
new_login GET /login/new(.:format) login#new
edit_login GET /login/:id/edit(.:format) login#edit
login GET /login/:id(.:format) login#show
PATCH /login/:id(.:format) login#update
PUT /login/:id(.:format) login#update
DELETE /login/:id(.:format) login#destroy
dashboard GET /dashboard(.:format) dashboard#index
dashboard_index GET /dashboard(.:format) dashboard#index
POST /dashboard(.:format) dashboard#create
new_dashboard GET /dashboard/new(.:format) dashboard#new
edit_dashboard GET /dashboard/:id/edit(.:format) dashboard#edit
GET /dashboard/:id(.:format) dashboard#show
PATCH /dashboard/:id(.:format) dashboard#update
PUT /dashboard/:id(.:format) dashboard#update
DELETE /dashboard/:id(.:format) dashboard#destroy
root GET / login#index
source
share