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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

