Category: Rails
-
Gem: Export to Excel
Creating excel spreadsheets (with charting) has never been easier. This looks like an amazing bit of code if you’re writing a data driven app that requires exporting to excel!
-
Rails Validating Field vs Association
One really interesting thing I came across recently is validating a field vs association. I’ve always written something like this (assume this is a… Company model with a attribute called owner_id and a belongs_to association called owner): What’s better to write is: This actually makes sure that your :owner_id actually maps to a real object in the database.…
-
Ruby on Rails: Deleting data models without deleting from database
Act as paranoid is a great little gem if you want to keep your models to hang around for audit purposes till some later process clears it out. Calling ActiveRecord.destroy first time removes it from all queries and the next destroy removes it from the database entirely. Fantastic. Rails 3.2 compatible.
-
Talking to a cross-domain API (CORS) with Backbone JS and Ruby on Rails
After doing a whole load of reading, the solution is absolutely simple. Here’s what to do. On your backbone (or any other client side JS) side, we add some jQuery goodness with the following method: This prefilter allowed all my BackboneJS calls to be hitting the remote API correctly. I’ve put this on my main.js…