Skip to content

Instantly share code, notes, and snippets.

@sawyerh
Created June 24, 2016 14:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sawyerh/ad120c575a79e346015a1d69e945ddac to your computer and use it in GitHub Desktop.
Save sawyerh/ad120c575a79e346015a1d69e945ddac to your computer and use it in GitHub Desktop.
Siteleaf on S3 + Rails
class BlogsController < ApplicationController
def index
@slug = params[:slug]
@file = AWS::S3.new.buckets['YOUR-SITELEAF-BUCKET-HERE']
.objects[File.join('blog', @slug.to_s, 'index.html')]
unless @file.exists?
puts @file.key
raise ActionController::RoutingError.new('Not Found')
end
end
end
<%= render :inline => @file.read %>
get 'blog(/*slug)' => 'blogs#index'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment