When you redirect_to
an object in Rails (which is what you're doing), the framework has a lot of built-in functionality to take care of things for you
One of these in-built features is the ability to detect & redirect to the object itself
Objects
When you pass @user
, you are passing a singular object, which Rails takes as meaning that you want to go to the show
view (you want to view the object, right?)
You need to remember that Ruby / Rails is Object Orientated. You're calling them @instance variables
, but really they are objects. Those objects contain a lot more data than your standard data - they contain information from the model & db
This means that if you build your @instance variable
in the conventional Rails way (using Model
data), you're going to get an object
--
Login
It seems to me that you're redirecting to the @user
object. However, I would imagine this will be covnered by your authentication system, hence why you're receiving the login
page
To fix this, you should try redirecting to specific paths, like this:
redirect_to users_path