Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rails初心者がSPAアプリを作ってみた話

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

 Rails初心者がSPAアプリを作ってみた話

Avatar for Kouichi(19)

Kouichi(19)

July 20, 2019
Tweet

More Decks by Kouichi(19)

Other Decks in Technology

Transcript

  1. システム構成 CloudFrontでルーティング ブラウザ CloudFront heroku S3 index.html /api/* Rails vue.js

    https://github.com/koty/glide-well-front https://github.com/koty/glide-well-api Railsだと何も考えずに herokuにpushするだけで動く。すご い。。。
  2. ActiveModelSerializers モデルのオブジェクトをJSONにしてくれるgem ネストしたJSONをpostして更新するきれいな方法がよく分からなかった w = params.permit(:id, :date, :kind, :impression) if

    @workout.update(w) update_details(@workout.id) def update_details(workout_id) WorkoutDetail.where(workout_id: workout_id).delete_all p = params.permit(:id, :date, :kind, :impression, workout_details: [:id, :menu_kind, :times, :distance, details = p[:workout_details] details.each do |detail| rec = WorkoutDetail.new(detail) rec.workout_id = workout_id rec.save end