Mary Dickson Diaz

Code, Life, Learning

Month: February 2016

how to use the wordpress rest api in rails

Folks, if you’re reading this over at, my Rails portfolio site, things are about to get real meta. Several weeks ago I RSVPed for a WordPress Developer’s meetup called Introduction to the REST API. I’ve used APIs with Rails, Angular, and in Twitterbots– an API (application program interface) is simply a way to transfer information from a server to a client, often using a format called JSON (JavaScript object notation). APIs are key to mobile apps that access the same database as a web based site. “REST” (representational state transfer) means that a system understands a set of standard verbs used to communicate over HTML, including: GET, POST, PUT, DELETE, etc. You can use an AJAX (asynchronous JavaScript and xml) call to transmit data via the REST verbs and either fetch data, post new data, update existing data, or delete a record, and the information will be persisted in a database somewhere behind the scenes.

That’s a lot of acronyms. Here have a picture:

how APIs work, sort of


Long story short: I’ve had this WordPress blog since I started coding, and since then I’ve coded other web sites “from scratch,” including a professional portfolio site, that are much easier for me to customize and that add legitimacy to my claim of web developer. So that is what I want to share with potential employers but I *also* want them to see my awesome technical blog posts so they will think “She sounds cool and writes good. Let’s pay her money in exchange for her time!” UNTIL NOW the way to do that was to direct people to this site,, and hope that they will also go check out, or vice versa. Awkward.

The WordPress API allows me to import blog posts from and render them as a tab on If you have any sort of non-WordPress site and you’d like to link to or display your blog posts, you can do that with the WordPress REST API. I’ll walk you through what I did to get this working in a Rails app:

Continue reading

go into the city


“Now get up and go into the city and you will be told what you must do.”

I’m not particularly religious, but this photo by my friend Andrea was so timely this morning it brought me nearly to tears.

I’m wavering these days, trying to figure out the best path forward. What to work on, what to study, where to spend my time and energy to appeal to potential employers. I’ve been kinda all over the place: I spent a week climbing the Code Wars code challenge rankings to #2 for my Code Fellows “clan.” I went back through the assignments for Code 301 (the class I TAed) and completed them myself, to make sure I thoroughly understand all the components of a MVC website. (301 is a new class, which is why I hadn’t completed the assignments previously.) I’ve been coding in JavaScript and Ruby. I tried Rails 5. I went (finally) to an Open Seattle meetup and met some great people with neat project ideas. I started learning vim!

What I know is this: when I try to plot my path forward from my living room, I get nowhere. So my goal for the remainder of the month is to figuratively and literally GO INTO THE CITY. Look around. Talk to people. And listen for the clues to what to do next.

try rails 5

Hey folks! Last week wrapped up my second teaching assistant commitment, and while I managed to get myself invited back (barely) (I have more to say about this), I’m taking a break to focus on building skills and job seeking.

On the menu for today: let’s talk Rails 5. This’ll be short, since I need to dive into it.

Screen Shot 2016-02-03 at 3.21.29 PM


BUT FIRST… version control.

Since I finished my Ruby on Rails training in 4.something, Rails released a beta version of 5.0, and Ruby has also released a new version, from 2.2 -> 2.3. I’ve fought hard against installing a ruby version manager after disastrous attempts with rvm and rbenv, which hate each other, and will leave your development environment totally FUBAR if you’re not careful. So I nuked everything and avoided any Ruby version control, until now– and now I know better, and there’s no longer any excuse. My instructor says “try chruby!” so chruby it is!

I followed these instructions… including the setup for powder, which is my Rails development server of choice. I installed Ruby 2.3.0 as default and 2.2.4 as a “so then we’ll have it”. Apparently I had been using a version of ruby called 2.2.3p173.  Gross. No more!:

(Oh right, I have to update to El Capital also. Dammit.)


So now we have software version control, sweeeeet. However, that version control does not extend to Rails, so how to play with the new version without destroying my current install (most recent stable version)?

Option 1: Clone the Rails repo and create a new Rails app from that starting point. 

I followed this guide for how to clone the Rails repo and then create a new Rails API app using the latest beta version (“edge”):

Fun! This worked as expected. I did have to run a bundle install before the bundle exec rails new etc would work. If you go this route, at the end your gemfile will contain this line:

gem 'rails', github: "rails/rails"

Option 2: Create a Rails app like normal and then update the gemfile with desired Rails version

Do you really have to clone the entire Rails repo? Probably not, right? In my second attempt, I tried to teach an existing Rails app to use the new version. The latest beta release in has this language for your gemfile:

gem 'rails', '~> 5.0', '>= 5.0.0.beta2'

However, that did not work. This did!

gem 'rails', '5.0.0.beta2'

I had to run a bundle update after bundle install, but otherwise everything went smoothly.


Well, my install worked a bit TOO well, and now all new Rails apps are initiating with 5.0. That was not my intention, but it should be easy enough to switch back if needed. Funny enough, when I run a new Rails app now, this is what the gemfile looks like:

gem 'rails', '>= 5.0.0.beta2', '< 5.1'

YMMV. Gentle reminder: Rails 5 is not currently recommended for production environments.

© 2017 Mary Dickson Diaz

Theme by Anders NorenUp ↑