...
| Code Block | ||
|---|---|---|
| ||
rails generate controller UploadFile # 프로젝트/app/controllers/upload_file_controller.rb가 생성됨. |
| Code Block |
|---|
#upload_file_controller.rbclass UploadFileController < ApplicationController
skip_before_action :verify_authenticity_token
def create uploaded = UploadFile.create(file: params[:file])
render json:{
'uploadPath': uploaded.file.url
}
end
end
|
1.4 데이터베이스 마이그레이션
| Code Block | ||
|---|---|---|
| ||
rails generate migration AddFileToUploadFile file:string # UploadFile에 파일을 담을 'file' 필드 추가 rake db:migrate |
...