A
A
Anton Misyagin2015-05-27 23:55:19
Ruby on Rails
Anton Misyagin, 2015-05-27 23:55:19

How to see all properties from users table in current_user(devise)?

I use gem devise in my project. There is a users table. It has a lot of fields that devise doesn't see. For example, there is a user balance: the balance field in the table.
I'm trying to achieve a balance reading in this style:
current_user.balance
Now I have to do this:

usr = User.find current_user.id
usr.balance

In webrick logs SELECT from users passes 2 times. Preferably 1.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Vsk, 2015-05-28
@sunnmas

The device cannot see or not see the fields. And the current user simply returns the model to which the device is attached.
If current_user.balance gives an error - write what.
If your device is not on the user, but, say, what STI, then write the output
current_user.class.to_s

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question