Last Updated: February 25, 2016
·
1.768K
· rebyn

Light 'CMS' with Google Drive gem for Ruby

I came across this gem today and can't help thinking about a light 'CMS' idea.

For example, if you're working on an About</code> page and your non-technical team member (or your customer) keeps on changing minor details in the text, it's gonna be a hell of a task to perform the edits and push the commits.

Active Admin</code> can be a solution, yet it requires tweaks to your database and administrative access.

With Google Drive gem</code> for Ruby, the thing is: it's just simple as editing a spreadsheet.

# Login
session = GoogleDrive.login("username@gmail.com", "mypassword")

# Read the worksheet
ws = session.spreadsheet_by_key("pz7XtlQC-PYx-jrVMJErTcg").worksheets[0]

# Get content of A3 cell
@ourVision = ws[3, 1]

Feel free to include HTML elements like a, div</code> in the cells. For Rails to render correctly, add:

@ourVision.html_safe
  • T.