Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

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

Rails • Asked by Basile Marquefave

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 !

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 30,005+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.