Created
June 24, 2016 14:08
-
-
Save sawyerh/ad120c575a79e346015a1d69e945ddac to your computer and use it in GitHub Desktop.
Siteleaf on S3 + Rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= render :inline => @file.read %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get 'blog(/*slug)' => 'blogs#index' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment