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

Ask A Question

Notifications

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

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

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

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

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.