dimanche 4 septembre 2016

Rails Last_enable Devise check User Online

I am using a gem for devise called Last_enable http://ift.tt/2bLRraJ and I would like to implement an if statement on my user view , to display a logo "Online" if this statement is true .
My user controller :

 def online
    online = User.where('last_seen > ?', 5.minutes.ago)
  end

the 'online' query works in console and return a user. I just dont really know how to implement that on my view, or do a check if this statement is valid :

 <% if #What should I write here to check if my user is online ? %>
   <%= image-tag('assets/true.png') %>
 <% else %>
   <%= image-tag('assets/point_red.png') %>
 <% end %>

Thanks in advance for your help !

Aucun commentaire:

Enregistrer un commentaire