Jump to content
Banner by ~ Kyoshi Frost Wolf
  • entries
    4
  • comments
    9
  • views
    2,906

Having fun from 6AM to 8AM coding Categories into Stories, and thus creating your own.


Neikos

697 views

Due to me being on holidays my sleep schedule slowly shifted towards the night. So I found myself coding early in the morning.

 

Somehow I thought that implementing categories into stories on the Canterlot Library was a good thing to do now, so I did that.

 

From a coding perspective it was a lot of fun, since when you're tired everything looks like the Mt. Everest.

 

My first iteration of the code worked. But it didn't really check if the categories are valid. So I had to change that. At the time I was using a Hash, which for those who don't know, is a data structure that is meant to hold key => value pairs. I then used one of ruby's methods which checks every single entry in the hash to be valid and then returns true only if every check also held true. Only, it also iterated over the keys, something I didn't want. That was easy to fix, but hard to find since it was returning true all the time! Either way, having found why my checks weren't working I once again remade everything, in what is in my opinion, the rails way. Aka:

 

.png

 

 

PS: It took me so long because I also helped a friend of mine with his programming, in reality this took me ~30 mins.

 

PPS: I love one liners.

 

 

Check out the result here: http://canterlotlibrary.com/stories/1-twilight-s-a-detective

 

Categories!

0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Join the herd!

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...