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 cn
Search
blue planet
May 29, 2013
Programming
0
200
rails cn
Rails 简单介绍
blue planet
May 29, 2013
Tweet
Share
More Decks by blue planet
See All by blue planet
dapp 開発における big number の落とし穴 / Pitfalls of the big number in dapp development
blueplanet
0
120
join.me使用方法
blueplanet
0
120
Sublime Text 2 プラグイン開発 - ゼロからPackageControlへ登録まで
blueplanet
5
1.9k
Other Decks in Programming
See All in Programming
Compose UIテストを使った統合テスト
hiroaki404
0
110
nekko cloudにおけるProxmox VE利用事例
irumaru
3
470
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
470
php-conference-japan-2024
tasuku43
0
370
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
4
900
return文におけるstd::moveについて
onihusube
1
1.3k
CloudflareStack でRAGに入門
asahiiwm
0
130
MCP with Cloudflare Workers
yusukebe
2
230
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
360
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
240
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
290
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1.1k
Featured
See All Featured
The Cult of Friendly URLs
andyhume
78
6.1k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
GitHub's CSS Performance
jonrohan
1031
460k
Building a Scalable Design System with Sketch
lauravandoore
460
33k
For a Future-Friendly Web
brad_frost
175
9.4k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Into the Great Unknown - MozCon
thekraken
34
1.5k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Six Lessons from altMBA
skipperchong
27
3.5k
Transcript
Ruby on Rails
ఏ纲 • Ruby 语ݴ • Ruby on Rails ᐽՍ •
ԋࣔ • Notes
Ruby 语ݴ • ٭ຊ语ݴ • ໘对 • 动态㜎ܕ • 语๏优ඒ
Ruby on Rails ᐽՍ • MVC WEB 䇖发ᐽՍ • FullStack
Ruby 语ݴ
RubyੋҰ㛭ՄҎࣸग़ 优ඒ码ɼ让䇖发ऀ ײ౸շ乐త语ݴ DHH - ຊITProࡃ访
٭ຊ语ݴ • ෆधཁ编译 • Ruby൛ Hello, world • $ ruby
-e 'puts "Hello, world !"'
໘对 • Ҏ㜎为ج础త໘对 • ॴ༗త东ੋ对 • “aaa”.class • 1.class
动态㜎ܕ • 变ྔᏠध໌㜎ܕ • ਵ时ՄҎमվ㜎ɺ对తߦ为
变ྔᏠध໌㜎ܕ • name = “yu” • age = 25 •
user = User.new
ਵ时ՄҎमվ㜎ɼ对తߦ为 class User def say “name is yu” end end
user = User.new user.say -> “name is yu” class User def hello “hello” end end user = User.new user.hello -> “hello”
语๏优ඒ • 变ྔෆधཁ㜎ܕ໌ • ׅ߸߸ՄҎলུ • @䇖头త为实ྫ变ྔ • @@䇖头త为㜎变ྔ •
େࣸతੋৗྔ
语๏优ඒ
Ruby on Rails ᐽՍ
历࢙ • 2004/07 First version • 2005/12 1.0 • 2007/12
2.0 • 2010/08 3.0 • 2013/05 4.0(rc1)
MVC • Model • View • Controller
http://japanese.railstutorial.org/chapters/a-demo-app
ཧ೦ • 约ఆ优ဋ设ஔ Convention over Configuration • ෆཁॏ䐾㟬ࣗݾ Don’t Repeat
Yourself
约ఆ优ဋஔ • User (Model) • models/user.rb • users (table in
DB)
约ఆ优ဋஔ • UsersController (Controller) • controllers/users_controller.rb
约ఆ优ဋஔ • users#index (View) • views/users/index.html.erb
ෆཁॏ䐾㟬ࣗݾ • Ұද • create_users.sql / ख动创ݐʁ • class User
... • User.xml • update_ver211to212.sql
ෆཁॏ䐾㟬ࣗݾ • Ұද • create_users.rb • class User ...
ෆཁॏ䐾㟬ࣗݾ • user.java • user.rb
user.java
user.rb
ํศతޭೳ • ֤䝅ੜث • 环ڥཧ • ਾ库൛ຊཧ • ߇੍
֤䝅ੜث • rails generate • controller • model • migration
• rails destory
级实༻త环ڥཧ • ᘍ认ࡾ环ڥ • 䇖发ʗ测试ʗੜ产 • Մࣗఆ义 • ࠜਾ环ڥෆಉ设ஔෆಉࢀ •
ൺɿ发ૹ邮݅༻త务ثᅿ
ํศతਾ库൛ຊཧ • rake db: • migrate / test:prepare • rollback
• reset • drop
߇੍ • rails console • Մҙ执ߦ码 • 查ਾ
ԋࣔ
༰ • ৽ݐrails项 • ༻rails g scaffold notes body •
⃧Ճ㜎