ruby on rails - I am trying to display the amount of time in minutes since an account was created -


i using devise authentication in rails. ran similar in rails console , displayed correct number.

here ran in console:

coles-macbook-pro-2:rq coleschiffer$ rails c loading development environment (rails 4.1.0) 2.1.1 :001 > (time.now - user.first.created_at.round)/60   user load (0.2ms)  select  "users".* "users"   order "users"."id" asc limit 1  => 1004.61901355  2.1.1 :002 > 

then used same class display live time difference here:

<% time.now - (user_created_at)/60.round %> 

but, errors keep popping up

undefined local variable or method `user_created_at' #<#<class:0x007fa66bfd0660>:0x007fa67186cc60>. 

thank help!

i'd move method model, this

class user < activerecord::base   def minutes_since_created     ((time.now - created_at) / 60).round   end end 

then in view

<%= current_user.minutes_since_created %> 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -