|
Ok, so now our Vine videos can be displayed, and the voting mechanism is in place! The next thing we need to do is setup the main page for the app – The Leaderboard! Our leaderboard, although being the main feature of the app, is incredibly simple. Open up the file app/views/vines/index.haml (or .erb) and ensure it matches the code here.
Now, if this were any ordinary relational Rails app, we should in theory have a leaderboard already created, listing each Vine video in our database. BUT this isn’t the case here.
In Couchbase, we need to create our leaderboard using Views in Couchbase and utilising the Map/Reduce technique before we get a leaderboard that actually works properly!
So, let’s do that! Before we proceed here, if you haven’t used Couchbase Views prior to this, I recommend you read these docs, to give you a good bit of background knowledge on what Couchbase Views are, how we use them and to ease your way into using them in this Rails application
For our application, we need to create a View in Couchbase, that outputs each vine, with it’s Score and Title. They also need to be ordered, descending, by Score so the Vine video with the highest score is naturally at the top of the Leaderboard.
|
|