Thursday, August 19, 2010

[Rails] Re: how to perform "most viewed"

nirosh wrote:
> i have a poem model. i need to display the most viewed poems.
> is there any plug inns out there to do this?

Unless I'm missing something obvious, I wouldn't think a plugin would be
needed for this.

poems_controller.rb
--------------------
def show
@poem = Poem.find(params[:id])
@poem.increment!(:view_count)
...
...
end

http://railsapi.com/doc/rails-v2.3.8/classes/ActiveRecord/Base.html#M001117
--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate