-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from larathordar/aws
Athletes images can be stored in aws cloud service
- Loading branch information
Showing
18 changed files
with
109 additions
and
18 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
class Athlete < ApplicationRecord | ||
validates :name, :age, :home, presence: true | ||
has_one_attached :image | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
class Athlete::ShowSerializer < ActiveModel::Serializer | ||
attributes :name, :age, :home, :starttime | ||
attributes :name, :age, :home, :starttime, :image | ||
|
||
def image | ||
unless object.image.attachment.nil? | ||
object.image.service_url(expires_in: 1.hour, disposition: 'inline') | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
class AthleteSerializer < ActiveModel::Serializer | ||
include Rails.application.routes.url_helpers | ||
attributes :name, :link, :home | ||
attributes :name, :link, :home, :image | ||
|
||
def link | ||
api_v1_athlete_url(object) | ||
end | ||
|
||
def image | ||
unless object.image.attachment.nil? | ||
object.image.service_url(expires_in: 1.hour, disposition: 'inline') | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
MckhkBgeP9c2MN502PBpQkcNBszdK5YX6k7KaWdMJa4XVU96Gj6Ah3aVXzQuFusbtbbcR1o3V6IuRd6CMZrboFcx398Q+aTnzerXlJWx6AmczRwmDLER6+MnuWw51N3bVFNZmTgfb2T3zBcrZsNHc6PUIakX3i+VGXBbtrrhGis7fmoFk4q5ay5YwtBd3YszYjVCQ3NHk4iyNimssQIZIJg+xxYFtHjec13VJdt4WCI/3sH9Cffd0iDL3Pzc9kiqLyyc8KAGe0zzeb4cofci81z+b3j0D2AkCNFP55tJ8Rm0TG8/i5WEu664X1klUDjJPx1R1gR0+B1rDrT3+bIdfI/5h4s40kqC3uFKz0uoteHAyPQeY0AY8c1yU49h/2SPZxC/HYPOQ6z6DSU+G/t6is1eDyFPvr3vhTc4--PcMzhR/7lgpZ60sb--7a8HeHPW40+uc+Z1F2h++g== | ||
ut8x0Vl45ypRpbBsurUM/eTTubSo7cpAMEhLU/43+gNL0zbr9gXk+Qf6yWxXlBPqafusQL96YupVaQzHsBfRBYJIKuz0Ea12qY2xQKMOdqvIjjRz3L3SPfs7qFqWnj+srTupYg7pklxqTqPYQSiPFIt20dMpW17o1/FMnW2TJKeQhSypQ5cSnSWUbSGiIMgkb+FHdXbdi1XtY/LvBspDBiwsDmrX8fno9HktyuSvvn6KAdr53AC0cjtt7amyCAS2RBPab6LCYWzpCNuGpPxibIPkCqleQv3vI7hHepQRBGbfIczqwH/amM7YwSJUUKOpoz/i2s0BJ/OVc474BUtsQYB3W68fX9qJGM8UL+WfXsR29Usj3JpcnFQhOy8t25HHJ+tN5v7FWrkSc4z9Kicktm18NQeK7xrSK83lCm3dS67OmteppeFg9UFQCvTX1T9QzZH9zjvFYvyVqETEItp3ij4+99wH--NojC0boXV2MgNu89--08jQ6RGrSWm+/bR8zxWgtA== |
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
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
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
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
26 changes: 26 additions & 0 deletions
26
db/migrate/20180405180045_create_active_storage_tables.active_storage.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# This migration comes from active_storage (originally 20170806125915) | ||
class CreateActiveStorageTables < ActiveRecord::Migration[5.2] | ||
def change | ||
create_table :active_storage_blobs do |t| | ||
t.string :key, null: false | ||
t.string :filename, null: false | ||
t.string :content_type | ||
t.text :metadata | ||
t.bigint :byte_size, null: false | ||
t.string :checksum, null: false | ||
t.datetime :created_at, null: false | ||
|
||
t.index [ :key ], unique: true | ||
end | ||
|
||
create_table :active_storage_attachments do |t| | ||
t.string :name, null: false | ||
t.references :record, null: false, polymorphic: true, index: false | ||
t.references :blob, null: false | ||
|
||
t.datetime :created_at, null: false | ||
|
||
t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true | ||
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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