###### tags: `Ruby` # 沙盒模式 (rails c --snadbox)  save後自動生出id 以及時間 第二次save變成update 檢查是否更動可以用xxx.changed? 如果要更改可以這樣如果要多筆一起更改 資料驗證這件事放在model這裡做 因為可以重複使用若是在controller裡做那每個controller都要再寫一次 model 以及資料庫都需要做驗證 加入驗證email、password必填 測試 # 實作 寫進資料庫前必須再驗證一次只靠token不夠 可以透過開發工具新增欄位 強參數過濾  password_confirm不再資料表欄位裡所以它不認得(虛擬欄位) 解決方案 將強參數變回私有方法 整理一下用user_params代替 每當定義方法都會再建立一個符號 ex: def cat 就會有一個 :cat 功能相同 不 失敗部分 不使用redirect 使用render :sign_up 使資料保留並用sign_up.html.erb的畫面再畫一次頁面     將 User.new 指定為@user,再sign_up設定實體變數@user 也把registration方法裡的變數設為@user因為registration裡 失敗時render sign_up頁面所以需要 @user這個變數因為我們將 form_for的參數改為@user 代替User.new 。故意湊成這樣的巧合  可把所有css打包成1個檔案 require_tree . require資料所有檔案 手動增加scss檔寫css讓錯誤時格式正常  讓錯誤時跑出訊息  在後面加上 取代原本的驗證  把原本的驗證刪掉  強參數裡的也要改 做更多限制 成果畫面 做登出按鈕 logout_path路徑 去對照表找   
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up