「Rubyエンジニアが語る2016年の振り返りとこれから」での発表資料です。 https://speee.connpass.com/event/47616/
前職と現職で2アウト案件。 Railsに限らないけど、ログインユーザの情報を変更するときは current_user みたいな変数を変更するんじゃなくて、DBを引き直して更新しましょうって話。 ダメな例 class ProfileController def update if current_user.update(profile_params) redirect_to :root else render :edit end end end 良い例 class ProfileController def update @user = User.find(current_user) if @user.update(profile_params) redirect_to :root else render :edit end end end なんでだめなの? バリデーションエラーが起きた時に
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く