hi, im trying to do: def show @advisor = Advisor.find(params[:id]) @advisor.reviews = @advisor.reviews + 1 #reviews is just an integer @advisor.save! .... how can i implement a "show"-counter? thx -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tom Tom wrote:> def show > @advisor = Advisor.find(params[:id]) > @advisor.reviews = @advisor.reviews + 1 #reviews is just an > integer > @advisor.save! > .... > how can i implement a "show"-counter?The first problem I see is that the "show" action typically uses a GET request. GET requests should be both idempotent and safe. Imagine what would happen if a user were to navigate to your show page and then just repeatedly refreshed the page. Every refresh would be a new request causing your count to be unreliable. For instance, if you were relying on this count to judge the popularity of a particular item it would be trivial for an end user to artificially promote whatever item they wish. I don''t know what your end goal is for such a feature, but generally speaking, such information is usually gleaned from web logs, rather than being implemented inside the application. There are also many web log analyzers available that people use to monitor web site usage. These will typically generate more useful reports than what you would care to generate yourself. For example, I would expect a good web log analyzer to show typical navigation paths through an web site. This information could be used to detect whether a user has navigated to the page from a different page, or simply refreshed the same page. This might indicate attempts to artificially raise the popularity of a given page. It might also indicate a problem with the page. Maybe the page is slow to respond prompting the user to attempt to "fix" it by pressing reload. Just some thoughts. Were you having a particular problem with your implementation, or just looking for advice and suggestions? -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Robert, thx 4 ur time and ur answer. im aware of analyzer(& their theory) as well of recording the users "browsing-behaviour-strategies". in that case, its a secured environment (users have to be logged in etc..) and if they do the SHOW-action, they will see a full profile of other registered users. so my question was just simple: why is it not incrementing? thx again best tom On Fri, Apr 9, 2010 at 7:44 PM, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Tom Tom wrote: > > def show > > @advisor = Advisor.find(params[:id]) > > @advisor.reviews = @advisor.reviews + 1 #reviews is just an > > integer > > @advisor.save! > > .... > > how can i implement a "show"-counter? > > The first problem I see is that the "show" action typically uses a GET > request. GET requests should be both idempotent and safe. Imagine what > would happen if a user were to navigate to your show page and then just > repeatedly refreshed the page. Every refresh would be a new request > causing your count to be unreliable. For instance, if you were relying > on this count to judge the popularity of a particular item it would be > trivial for an end user to artificially promote whatever item they wish. > > I don''t know what your end goal is for such a feature, but generally > speaking, such information is usually gleaned from web logs, rather than > being implemented inside the application. > > There are also many web log analyzers available that people use to > monitor web site usage. These will typically generate more useful > reports than what you would care to generate yourself. > > For example, I would expect a good web log analyzer to show typical > navigation paths through an web site. This information could be used to > detect whether a user has navigated to the page from a different page, > or simply refreshed the same page. This might indicate attempts to > artificially raise the popularity of a given page. It might also > indicate a problem with the page. Maybe the page is slow to respond > prompting the user to attempt to "fix" it by pressing reload. > > Just some thoughts. Were you having a particular problem with your > implementation, or just looking for advice and suggestions? > -- > Posted via http://www.ruby-forum.com/. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
tada'' ;-) http://www.railsrocket.com/articles/efficiently-incrementing-model-attribute-values On Fri, Apr 9, 2010 at 8:37 PM, tom <tomabroad-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Robert, thx 4 ur time and ur answer. im aware of analyzer(& their > theory) as well of recording the users "browsing-behaviour-strategies". > > in that case, its a secured environment (users have to be logged in etc..) > and if they do the SHOW-action, they will see a full profile of other > registered users. so my question was just simple: why is it not > incrementing? > thx > again > best tom > > > On Fri, Apr 9, 2010 at 7:44 PM, Robert Walker <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote: > >> Tom Tom wrote: >> > def show >> > @advisor = Advisor.find(params[:id]) >> > @advisor.reviews = @advisor.reviews + 1 #reviews is just an >> > integer >> > @advisor.save! >> > .... >> > how can i implement a "show"-counter? >> >> The first problem I see is that the "show" action typically uses a GET >> request. GET requests should be both idempotent and safe. Imagine what >> would happen if a user were to navigate to your show page and then just >> repeatedly refreshed the page. Every refresh would be a new request >> causing your count to be unreliable. For instance, if you were relying >> on this count to judge the popularity of a particular item it would be >> trivial for an end user to artificially promote whatever item they wish. >> >> I don''t know what your end goal is for such a feature, but generally >> speaking, such information is usually gleaned from web logs, rather than >> being implemented inside the application. >> >> There are also many web log analyzers available that people use to >> monitor web site usage. These will typically generate more useful >> reports than what you would care to generate yourself. >> >> For example, I would expect a good web log analyzer to show typical >> navigation paths through an web site. This information could be used to >> detect whether a user has navigated to the page from a different page, >> or simply refreshed the same page. This might indicate attempts to >> artificially raise the popularity of a given page. It might also >> indicate a problem with the page. Maybe the page is slow to respond >> prompting the user to attempt to "fix" it by pressing reload. >> >> Just some thoughts. Were you having a particular problem with your >> implementation, or just looking for advice and suggestions? >> -- >> Posted via http://www.ruby-forum.com/. >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tom Tom wrote:> tada'' > ;-) > > http://www.railsrocket.com/articles/efficiently-incrementing-model-attribute-valuesNice. Looks like exactly what you were wanting. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.