class Creative

attr_reader :name, :passion, :professions

def initialize(name, passion, professions)
@name = name
@passion = passion
@professions = professions
end

glenn = Creative.new( "Glenn Langdon", "creativity", [ "conduct orchestras", "play the piano", "write", "code" ])
puts "Hi, I'm #{glenn.name} and I'm passionate about #{glenn.passion}."

glenn.professions.each do |skill|
puts "I #{skill}."
end
end

Rails 5 blog with Coderay syntax highlighter

If you have a Rails blog, there are many choices available for syntax highlighting to make your code more visually interesting. Coderay has been around a while and is very good at syntax highlighting for the two dozen or so input languages it supports. Ryan Bate's excellent Railcast of 2010 is a bit out-dated in a couple of respects, but the essentials are still valid. I'll demonstrate a quick implementation for the...

11 January 2017

Sitemap for Rails blog

Sitemaps are XML files that provide a map of your URLs to Google and other search engines. They can be especially useful for Rails applications, like a blog, where all the the links may not appear browseable. There are many ways to code a sitemap for a Rails application, but I'll show you a very simple and quick method to get your sitemap up and running in minutes.

Let's assume you already have a working...

31 December 2016

Rails 5: Bootstrap Carousel w/ Rails helper methods

Integrating a Bootstrap image carousel into a static webpage is fairly easy. It's basically copying and pasting from the Bootstrap website, with the developer just needing to add the image links. Even adding the necessary Bootstrap plug-ins to Rails is straightforward. But, what if you want to use the native Rails helper methods, link_to and image_tag? There's a dearth of information about how to keep your Rails app railsy when using this light-weight...

23 December 2016

Ruby on Rails: Multiple blog post previews on a home page

Having built a blog, I wanted the user to be able to preview 4 blog entries on the landing page. Not wanting to hard code the article paths, I wanted the code to automatically pull the four most recent posts. Some very simple Ruby methods to the rescue.

First, I wanted to list the four most recent entries, sorted from the oldest to the most recent, from the database of my blog entries....

18 November 2016

Using Heroku, AWS S3, CKEditor and Paperclip in a Rails 4 app

Recently I built a Rails blog with a WYSIWYG editor, CKEditor, that allows a user to upload pictures and post articles via the text editor. CKEditor is one of the full-featured text editors that developers can easly integrate into their applications. For uploads, I chose Paperclip, a powerful file attachment library for ActiveRecord. Since Heroku uses an ephemeral filesystem, static assets such as picture uploads must be stored elsewhere. Therefore, I'll use AWS' Simple Storage...

11 October 2016