Moving from ActiveModel::Serializers to FastJsonAPI
How to get HTTPS working on your local Rails server on Ubuntu
After reading a bunch of tutorials on the subject and trying out a variety of suggestions, here’s the shortest path I found to localhost HTTPS bliss on Ubuntu for Rails:
Make FactoryGirl Respect Uniqueness When Creating Associations
If you have an ActiveRecord model associated with another model that has a uniqueness constraint, modeling it in FactoryGirl when writing specs doesn’t work out of the box. But there is a simple solution.
Spying on Function Calls in Jasmine Doesn’t Work as You Expect It To
Say you want to test that a function is called in your javascript code. What could be simpler, you say. Just write a simple Jasmine spec, throw a spy in, and you are set. That’s what I thought, before stumbling on a weird issue.
Adding Recurrence Rule to Generated ICS file in Rails
If you need to integrate your Rails app with some calendaring service, such as Google Calendar, sooner or later you will find yourself writing code that outputs your Event object as an ICS file. But if your events have recurrence rules, you are out of luck, the popular Icalendar gem doesn’t support them. I’ll show how to make it work.
Document your Rails API by Writing Acceptance Specs
So you have been working on a Rails API, and now you need to create a browsable HTML documentation for it. One popular approach is to generate the docs from comments in the code. The problem with this is that comments are often not updated together with the code, and the documentation quickly becomes outdated. Recently I have started using an interesting alternative: Rspec Api Documentation.
Rspec Shared Contexts Have to Be Included Separately (Sometimes)
Let’s say you have two shared_context blocks in your rspec spec that each redefines the same variable or mocks the same method:
Integrate ConverseJS with Rails The Easy Way
If you ever needed to add chat to your Rails app, than you are probably familiar with the ConverseJS library, which is a great XMPP/Jabber compatible javascript client. But until today there was no asset-pipeline compatible gem that would add converse.js and converse.css to your app. As you probably know, adding external js and css files manually isn’t ideal, since it makes it harder to maintain and update versions.
Well, now there is: