I have added to my eWorm Rails Web App in a few feature branch. This addition focuses on using jQuery scripts and a JSON API backend to load and update data on the server without needing to refresh the page.
I created a JSON backend, which is very easy with rails! My books serializer looks like this:
And then I just had to create simple serializers for the other models like so:
After this, is it was just a matter of updating a few controller actions to allow access via JSON like so:
I added an additional feature, a genre filter on the books index page. It’s a nice fast, and clean way to filter the books by genre without refreshing the page! Check out this code snippet:
I on the books index page, I also implemented a form that could be toggled viewable, and when submitted would auto-magically add the new book to the page! This was fun and I could see this as a practical feature for some websites as it could reduce the time it takes to add content.