Ask A Question


You’re not receiving notifications from this thread.

How to display and order model result with Ahoy::Event?

Basile Marquefave asked in Rails

hi all,

I’m stuck with Gem Ahoy.

In my rails app, i have a Room model, each Room has many subject.

After installing Ahoy, i succeed to display the Ahoy::Event result (=number of views) for each subject, but i’m stuck to display the last 5 most viewed subject in my Room dashboard (subject with most Ahoy::Event id).

I'm able to display for one specific subject

<%= Ahoy::Event.where_props(subject_id: 121).count %>

but stuck for order all subject of a Room by Ahoy::Event result (most viewed)

I tried many stuff but nothing working.

Any Idea ?

Thanks so much !

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 77,200+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2023 GoRails, LLC. All rights reserved.