Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
[教育訓練] Rails Validation Basic
Search
HeChien Hsu
September 04, 2012
Technology
92
1
Share
[教育訓練] Rails Validation Basic
HeChien Hsu
September 04, 2012
More Decks by HeChien Hsu
See All by HeChien Hsu
Using Git hosting
hechien
0
51
[Kaohsiung Rails meetup] 國際化影片分享網站
hechien
0
180
[Wheel Lab #2] Apple Service with Rails.
hechien
0
90
[Sokoos][教育訓練] Git - 1
hechien
0
160
[數位教學] 用Bootstrap製作網頁
hechien
0
1.3k
DesignYou - 專題報告投影片
hechien
0
130
[作業] 創意美學
hechien
0
65
[教育訓練] Rails Form Basic
hechien
1
82
Rails Layout Basic
hechien
2
130
Other Decks in Technology
See All in Technology
RedmineをAIで効率的に使う検証
yoshiokacb
0
130
AI全盛の今だからこそ、あえてもう一度振り返るAPIの基礎
smt7174
3
110
"うちにはまだ早い"は本当? ─ 小さく始めるPlatform Engineering入門
harukasakihara
6
620
おいらのAWSアップデートの追い方〜Slack×AgentCore〜
yakumo
1
110
Terragrunt x Snowflake + dbt で作るマルチテナントなデータ基盤構築プラットフォーム
gak_t12
0
250
インプロセスQAのための要因から捉えるプロジェクトリスクマネジメントnano #1 開発リソース効率状態への対処 #jasstnano
barus_qa
0
150
クラウドからエッジまで ~ 1,700台を支える監視設計~
optfit
0
110
サイボウズ、プラットフォームエンジニアリング始めるってよ ― プラットフォームチームの事業貢献と組織アラインメントの強化
ueokande
0
120
ECSのTerraformモジュールにコントリビュートした話
harukasakihara
0
220
Databricks 月刊サービスアップデートまとめ 2026年04月号
tyosi1212
0
130
Swift Sequence の便利 API 再発見
treastrain
1
290
エムスリーテクノロジーズ株式会社 エンジニア向け紹介資料 / M3 Technologies Company Deck
m3_engineering
0
180
Featured
See All Featured
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
210
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
300
Designing for humans not robots
tammielis
254
26k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
390
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
360
エンジニアに許された特別な時間の終わり
watany
106
240k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
170
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Transcript
Rails Validation 徐赫謙
Rails Validation Basic
會經過驗證的 • create • create! • save • save! •
update • update_attributes • update_attributes!
注意 • 有驚嘆號的(save!)驗證失敗會丟例外 • 沒驚嘆號的驗證失敗會回傳 • false: save, update_attributes •
物件: create, update
不會經過驗證的 decrement! • decrement_counter • increment! • increment_counter • toggle!
• touch • update_all • update_attribute • update_column • update_counters
⼿手動跟驗證說掰掰 save({validate: false})
Demo https://gist.github.com/3508269#file_02_demo.rb
valid? invalid? https://gist.github.com/3508269#file_01_valid_invalid.rb
errors[] https://gist.github.com/3508269#file_01_valid_invalid.rb
helpers • acceptance • confirmation • exclusion • format •
uniqueness • inclusion • length • numericality • presence • size • validates_associated
Example https://gist.github.com/3508269#file_04_demo.rb