Ruby on Rails Wednesday, December 19, 2012

hey,

it actually is possible to do that... however, it will get very complex when you want to have statistics and i would recommend something like new relic or google analytics to use then... but thats not what you asked for... so her i give you a quick and dirty example how you could do that:

rails g model Visit date:time ip:string (and what not you want to have)

then in your application_controller:

before_filter :track

def track
  trackobject = Track.new(:date => Time.now, :ip => "#{request.env['REMOTE_ADDR']}") unless session[:tracked] (and again what you want to have

 session[:tracked] = true (if you want that visitor only tracked once on your page
end

Am Mittwoch, 19. Dezember 2012 07:54:20 UTC+1 schrieb Maddy:
Hi Everyone,

Good Day!

I wanna to add to my blog a counter for displaying, how many times was my website visited. I would like to solve it through ruby (not GA or something like that). Is available any gem that do this task (also with checking IP address,the time of latest visited and visited count).


Please Advice.

Thank You.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/E51rE_WJrsEJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment