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
1
73
[教育訓練] Rails Validation Basic
HeChien Hsu
September 04, 2012
Tweet
Share
More Decks by HeChien Hsu
See All by HeChien Hsu
Using Git hosting
hechien
0
40
[Kaohsiung Rails meetup] 國際化影片分享網站
hechien
0
160
[Wheel Lab #2] Apple Service with Rails.
hechien
0
68
[Sokoos][教育訓練] Git - 1
hechien
0
150
[數位教學] 用Bootstrap製作網頁
hechien
0
1.3k
DesignYou - 專題報告投影片
hechien
0
100
[作業] 創意美學
hechien
0
48
[教育訓練] Rails Form Basic
hechien
1
61
Rails Layout Basic
hechien
2
110
Other Decks in Technology
See All in Technology
Azure App Service on Linux の Sidecar に Phi-3 を配置してインテリジェントなアプリケーションを作ってみよう/jazug-anniv14
thara0402
0
410
Qdrant を用いた検索改善施策の紹介 / Search Engineering Tech Talk 2024 Summer
visional_engineering_and_design
0
110
テストコードの品質を客観的な数値で担保しよう〜Mutation Testのすすめ〜
ysknsid25
12
3.1k
過去のインプットとアウトプットを振り返る
diggymo
0
110
分析者起点の企画を成功させた連携面の工夫
lycorptech_jp
PRO
1
250
Pythonを活用したLLMによる構造的データ生成の手法と実践
brainpadpr
3
340
Oracle Database 23ai 新機能#4 Application Continuity
oracle4engineer
PRO
0
120
AWS Lambdaで実現するスケーラブルで低コストなWebサービス構築/YAPC::Hakodate2024
fujiwara3
7
3.2k
AWSへのNIST SP800-171管理策 導入に向けての整備/20240930 Mitsutoshi Matsuo
shift_evolve
0
210
入門 バックアップ
ryuichi1208
18
6.7k
「ばん・さく・つき・たー!」にならないためにSHIROBAKOから 学んだこと
ysknsid25
3
670
業務ヒアリングと知識の呪い
tamai_63
0
280
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Building Better People: How to give real-time feedback that sticks.
wjessup
362
19k
Art, The Web, and Tiny UX
lynnandtonic
296
20k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
46
4.9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
355
29k
Ruby is Unlike a Banana
tanoku
96
11k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
32k
Writing Fast Ruby
sferik
626
60k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Typedesign – Prime Four
hannesfritz
39
2.3k
Designing with Data
zakiwarfel
98
5.1k
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