Hi, I am new to RoR and and web designing. I want to display page view count on my home page. How do I do that? Many thanks, Tyche --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, Here''s what you _could_ do, you could create a PageHit model which might contain: request_uri and created_at. Every time a page is viewed, add a new one of these objects. To ensure they are for page views, you could add code for this to the top of your layouts (application.rhtml in layouts, or whatever layouts your using). ie, in application.rhtml <% PageHit.create :request_uri => request.request_uri %> Cheers, James On 6/9/07, Tyche <chandra.sonia-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi, > I am new to RoR and and web designing. I want to display page view > count on my home page. How do I do that? > > Many thanks, > Tyche > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
James, This looks straight forward. But, this is only increase the load on the DB. Everytime a URL is requested, we create transcations on DB. Is there a better way of doing this? Another way, as far as I understand is creating a pattern in the logs and parse it to get the hit or view count. But, we can run the parser only periodically....making it non-real time. Does anyone have a better way or suggest a plugin???? On Jun 9, 2:25 pm, "James Brooks" <white...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > Here''s what you _could_ do, you could create a PageHit model which might > contain: request_uri and created_at. Every time a page is viewed, add a new > one of these objects. To ensure they are for page views, you could add code > for this to the top of your layouts (application.rhtml in layouts, or > whatever layouts your using). > > ie, in application.rhtml > <% PageHit.create :request_uri => request.request_uri %> > > Cheers, > James > > On 6/9/07, Tyche <chandra.so...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Hi, > > I am new to RoR and and web designing. I want to display page view > > count on my home page. How do I do that? > > > Many thanks, > > Tyche- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---