Reputation: 27
below my the app controller and routes, normally when i open localhost:3000 its show me the positions/new page, now i get redirected to the login page which is good, but after logging in it does nothing .... while it should be routed to 'positions#new'
class ApplicationController < ActionController::Base
before_action :authenticate_user!
end
routes:
Rails.application.routes.draw do
devise_for :users
root to: 'positions#new'
resources :positions
end
Upvotes: 0
Views: 29
Reputation: 27
i added the sessions controller but it doesn't change anything. I also tested it in
pry: ➜ positionupdate git:(master) ✗ rails c
[1] pry(main)> User.count
(0.7ms) SELECT COUNT(*) FROM "users"
=> 0
but i gives me 0 users, while i signed in/up and i have a test user in my seeds, and i runned rails db:drop db:create db migrate db:seed
below my seeds
User.destroy_all
puts 'Creating user...'
users_attributes = [
{
email: '[email protected]',
password: '******',
barge_name: 'Barcelona',
},
]
User.create!(users_attributes)
puts 'Finished!
Upvotes: 0
Reputation: 1206
If u are using Devise you need to overwrite after_sign_in_path
method in your SessionsController < Devise::SessionsController
def after_sign_in_path
"/positions/new"
end
Your SessionController
should look like this:
class SessionsController < Devise::SessionsController
private
def after_sign_in_path_for(resource)
"/positions/new"
end
end
Upvotes: 1