Slide 18
Slide 18 text
first_5_press_releases = PressRelease.where(status: :published).first(5)
first_5_media_records = MediaRecord.where(status: :published).first(5)
renderer = ActionView::Base.new("#{Rails.root}/app/views/")
renderer.assign(press_releases: first_5_press_releases)
renderer.assign(media_records: first_5_media_records)
html = renderer.render(template: "home.html.haml",
layout: "layouts/application.html.haml")
s3_client = Aws::S3::Client.new
s3_client.put_object(
acl: "private",
body: html,
bucket: "stg-cosmos-assets",
content_type: "text/html; charset=UTF-8",
cache_control: "no-store, no-cache",
key: "index"
)
s3_publisher.rb
(トップページの例)