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
210
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
2k
Other Decks in Programming
See All in Programming
[Fin-JAWS 第38回 ~re:Invent 2024 金融re:Cap~]FaultInjectionServiceアップデート@pre:Invent2024
shintaro_fukatsu
0
400
負債になりにくいCSSをデザイナとつくるには?
fsubal
9
2.3k
WebDriver BiDiとは何なのか
yotahada3
1
140
AHC041解説
terryu16
0
590
Grafana Loki によるサーバログのコスト削減
mot_techtalk
1
110
sappoRo.R #12 初心者セッション
kosugitti
0
230
バックエンドのためのアプリ内課金入門 (サブスク編)
qnighy
8
1.7k
チームリードになって変わったこと
isaka1022
0
190
個人アプリを2年ぶりにアプデしたから褒めて / I just updated my personal app, praise me!
lovee
0
340
Conform を推す - Advocating for Conform
mizoguchicoji
3
680
Pythonでもちょっとリッチな見た目のアプリを設計してみる
ueponx
1
480
2024年のWebフロントエンドのふりかえりと2025年
sakito
1
230
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
GraphQLとの向き合い方2022年版
quramy
44
13k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
How STYLIGHT went responsive
nonsquared
98
5.3k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
27
1.9k
Adopting Sorbet at Scale
ufuk
74
9.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Making the Leap to Tech Lead
cromwellryan
133
9.1k
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 •
⃧Ճ㜎