Listing 3. showme_controller.rb class ShowmeController < ApplicationController def piglatin_sentence # Get the headline sentence = params[:future_headline] words = sentence.split sentence = "" # Go through each word, applying the secret # Pig Latin algorithm words.each do |word| if word =~ /^[aeiou]/i word << "way" else first_letter = word.slice(0,1) rest = word.slice(1..-1) word = "#{rest}#{first_letter}ay" end sentence << word sentence << " " end render :text => sentence end end