mercredi 29 novembre 2017

selecting username using current_user in devise

I read that the helper current_user can be called in the view. So I have something like this

<h1> Customer id <%= User.select(:username).find(current_user).id %> </h1>

The equivalent of what I am trying to do in SQL is the following

SELECT username FROM users WHERE id = current_user

I am not sure what I am doing wrong. I'm getting this error message:

undefined local variable or method `current_user' for ApplicationController:Class

Aucun commentaire:

Enregistrer un commentaire