I'm trying to create a rails 5 applications with devise that's supposed to act like a social network, so every user has a profile.
After updating the user instead of going back to the profile, the server redirects to localhost, then there is a message Filter chain halted as :require_no_authentication rendered or redirected
and only then the user profile is loaded.
Also on the profile a message is shown "You are already signed in".
My goal is to erase those redirects.
- I tried to change the redirect in a custom
RegistrationController
but then it said there are too many redirects so I could't just replace it. - I tried to have different roots for authenticated and unauthenticated users in
routes.rb
but it didn't change the behaviour - I tried to get behind the
:require no authentication
but I'm actually not quite sure I understood it correctly and also it didn't change anything. - The
after_sign_in_path_for
is set to the user profile
This is the server output:
Started PUT "/users" for 127.0.0.1 at 2019-06-04 12:13:37 +0200
Processing by Users::RegistrationsController#update as HTML
Parameters: {"email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmat
ion"=>"[FILTERED]", "current_password"=>"[FILTERED]"}, "commit"=>"Update"}
User Load (0.8ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
User Load (0.6ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT
1
(0.3ms) BEGIN
(0.4ms) COMMIT
Redirected to http://localhost:3000/
Completed 302 Found in 295ms (ActiveRecord: 2.1ms)
Started GET "/" for 127.0.0.1 at 2019-06-04 12:13:37 +0200
Processing by Users::SessionsController#new as HTML
User Load (0.7ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER
BY `users`.`id` ASC LIMIT 1
Redirected to http://localhost:3000/users/1
Filter chain halted as :require_no_authentication rendered or redirected
Completed 302 Found in 15ms (ActiveRecord: 0.7ms)
Started GET "/users/1" for 127.0.0.1 at 2019-06-04 12:13:37 +0200
Processing by UsersController#show as HTML
Parameters: {"id"=>"1"}
User Load (0.6ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER
BY `users`.`id` ASC LIMIT 1
User Load (0.5ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT
1
Rendering users/show.html.erb within layouts/application
Rendered users/show.html.erb within layouts/application (1.1ms)
Rendered shared/_navbar.html.erb (0.7ms)
Completed 200 OK in 162ms (Views: 145.3ms | ActiveRecord: 1.1ms)
Also why does the user get signed in again after updating? Is it correct behaviour? I cannot seem to fathom where the redirect to localhost ist happening and intervene. Any help would be appreciated.
Edit 1
So, to clarify. I tried to use an authenticated_root
but then I get the errormessage Couldn't find User without an ID
.
devise_scope :user do
authenticated :user do
root to: 'users#show', as: :authenticated_root
end
root to: 'users/sessions#new'
end
Also I can't manage to change the redirecting from to root to the user profile. So the RegistrationController
is unchanged. I would like to say in the update method or somewhere else "after updating go to user profile".