SlideShare a Scribd company logo
1 of 12
rails 初探
about me
• 望帆 ( 林满佳 )
• 微博: @ 天涯望帆
• emil : tywf91@gmail.com
为什么使用 ra ils
• 有太多理由让我用 python 的框架了
  – 有 python 编程基础
  – ruby 零基础
  – 用 django 写过几个小网站
• 为什么使用 ruby on rails
  – 方便简单
  – 完全是兴趣驱动的
一个月的 rails 学习历程
• 起初对 ruby 的元编程不是了解,走了不少
  弯路,期间看了一下 ruby 元编程,跨入
  rails 真正学习之道
• 对 rails 两个设计原则的理解
 – 惯例优于设定
 – 不做重复的事
惯例优于设定
• 在 django 每一个视图(对应 rails 的控制
  器)你都得指定一个模版,最简单的如下
  :
惯例优于设定
• rails 的简单实现
不做重复的事情
• 从大的方面来说,这个体现在 rails 的插件
  体系
• 从小的角度,这需要利用好 rails 提供的一
  些模式,逐步优化,逐步抽象,把正确的
  代码,放在正确的目录
• 比如,公共的一些类,或者模版放在 lib 目
  录
rails 小玩具
• rails new teachpary
• 修改 Gemfile



•   bundle install
•   rails generate scaffold person name:string
•   rake db:migrate
•   rails generate controller raffle
rails 小玩具
•   vim config/routes.rb
•   添加
•   resources :raffle, :only => ['show']
•   vim app/controllers/raffle_controller.rb
rails 小玩具
• 新建 app/views/raffle/show.html.erb




•   rake routes
•   rails server
•   http://0.0.0.0:3000/people
•   http://0.0.0.0:3000/raffle/{1,2,3,...}
参考资料
• http://guides.rubyonrails.org/index.html
• http://ihower.tw/rails3/
谢谢观赏

More Related Content

What's hot

Ruby中的常量与rails中常量的加载
Ruby中的常量与rails中常量的加载Ruby中的常量与rails中常量的加载
Ruby中的常量与rails中常量的加载Yuan Cheung
 
使用 laravel 的前與後
使用 laravel 的前與後使用 laravel 的前與後
使用 laravel 的前與後Shengyou Fan
 
Spring mvc
Spring mvcSpring mvc
Spring mvcpepsixp
 
Schema & Migration操作
Schema & Migration操作Schema & Migration操作
Schema & Migration操作Shengyou Fan
 
View 與 Blade 樣板引擎
View 與 Blade 樣板引擎View 與 Blade 樣板引擎
View 與 Blade 樣板引擎Shengyou Fan
 
Route 路由控制
Route 路由控制Route 路由控制
Route 路由控制Shengyou Fan
 

What's hot (7)

Ruby中的常量与rails中常量的加载
Ruby中的常量与rails中常量的加载Ruby中的常量与rails中常量的加载
Ruby中的常量与rails中常量的加载
 
使用 laravel 的前與後
使用 laravel 的前與後使用 laravel 的前與後
使用 laravel 的前與後
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Schema & Migration操作
Schema & Migration操作Schema & Migration操作
Schema & Migration操作
 
View 與 Blade 樣板引擎
View 與 Blade 樣板引擎View 與 Blade 樣板引擎
View 與 Blade 樣板引擎
 
HTML 語法教學
HTML 語法教學HTML 語法教學
HTML 語法教學
 
Route 路由控制
Route 路由控制Route 路由控制
Route 路由控制
 

Similar to Rails 初探

⼤語⾔模型 LLM 應⽤開發入⾨
⼤語⾔模型 LLM 應⽤開發入⾨⼤語⾔模型 LLM 應⽤開發入⾨
⼤語⾔模型 LLM 應⽤開發入⾨Wen-Tien Chang
 
Intro to Rails Workshop ( TA 須知 )
Intro to Rails Workshop ( TA 須知 )Intro to Rails Workshop ( TA 須知 )
Intro to Rails Workshop ( TA 須知 )Yi-Ting Cheng
 
Kamigo reviews 20191127
Kamigo reviews 20191127Kamigo reviews 20191127
Kamigo reviews 20191127Jia Yu Lin
 
Rails ABC
Rails ABCRails ABC
Rails ABCqtlove
 
How to upgrade_ror3_to_ror4
How to upgrade_ror3_to_ror4How to upgrade_ror3_to_ror4
How to upgrade_ror3_to_ror4Wei-Yi Chiu
 
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器Chieh Kai Yang
 
Ruby rails分享
Ruby rails分享Ruby rails分享
Ruby rails分享Cam Song
 
Ruby Rails 老司機帶飛
Ruby Rails 老司機帶飛Ruby Rails 老司機帶飛
Ruby Rails 老司機帶飛Wen-Tien Chang
 
Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務
Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務
Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務Mu-Fan Teng
 
J Ruby和Rails 让Ruby语言融入Java项目
J Ruby和Rails 让Ruby语言融入Java项目J Ruby和Rails 让Ruby语言融入Java项目
J Ruby和Rails 让Ruby语言融入Java项目George Ang
 
Rails 新人起步走
Rails 新人起步走Rails 新人起步走
Rails 新人起步走jimmy lin
 
Rails 新人起步走
Rails 新人起步走Rails 新人起步走
Rails 新人起步走政億 林
 
合久必分,分久必合
合久必分,分久必合合久必分,分久必合
合久必分,分久必合Qiangning Hong
 
课题二:Node.js那些事儿
课题二:Node.js那些事儿课题二:Node.js那些事儿
课题二:Node.js那些事儿Liu Allen
 
A brief introduction to Machine Learning
A brief introduction to Machine LearningA brief introduction to Machine Learning
A brief introduction to Machine LearningWen-Tien Chang
 
How to ASP.NET MVC4
How to ASP.NET MVC4How to ASP.NET MVC4
How to ASP.NET MVC4Daniel Chou
 
Build line notify bot by lotify and create client library by swagger 20200527
Build line notify bot by lotify and create client library by swagger 20200527Build line notify bot by lotify and create client library by swagger 20200527
Build line notify bot by lotify and create client library by swagger 20200527Jia Yu Lin
 
Ruby 的快与慢
Ruby 的快与慢Ruby 的快与慢
Ruby 的快与慢vincent253
 
開發環境建置
開發環境建置開發環境建置
開發環境建置Shengyou Fan
 
從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用謝 宗穎
 

Similar to Rails 初探 (20)

⼤語⾔模型 LLM 應⽤開發入⾨
⼤語⾔模型 LLM 應⽤開發入⾨⼤語⾔模型 LLM 應⽤開發入⾨
⼤語⾔模型 LLM 應⽤開發入⾨
 
Intro to Rails Workshop ( TA 須知 )
Intro to Rails Workshop ( TA 須知 )Intro to Rails Workshop ( TA 須知 )
Intro to Rails Workshop ( TA 須知 )
 
Kamigo reviews 20191127
Kamigo reviews 20191127Kamigo reviews 20191127
Kamigo reviews 20191127
 
Rails ABC
Rails ABCRails ABC
Rails ABC
 
How to upgrade_ror3_to_ror4
How to upgrade_ror3_to_ror4How to upgrade_ror3_to_ror4
How to upgrade_ror3_to_ror4
 
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
改善 Angular 開發流程:你所不知道的 Schematics 程式碼產生器
 
Ruby rails分享
Ruby rails分享Ruby rails分享
Ruby rails分享
 
Ruby Rails 老司機帶飛
Ruby Rails 老司機帶飛Ruby Rails 老司機帶飛
Ruby Rails 老司機帶飛
 
Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務
Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務
Mopcon2014 - 使用 Sinatra 結合 Ruby on Rails 輕鬆打造完整 Full Stack 網站加 API Service服務
 
J Ruby和Rails 让Ruby语言融入Java项目
J Ruby和Rails 让Ruby语言融入Java项目J Ruby和Rails 让Ruby语言融入Java项目
J Ruby和Rails 让Ruby语言融入Java项目
 
Rails 新人起步走
Rails 新人起步走Rails 新人起步走
Rails 新人起步走
 
Rails 新人起步走
Rails 新人起步走Rails 新人起步走
Rails 新人起步走
 
合久必分,分久必合
合久必分,分久必合合久必分,分久必合
合久必分,分久必合
 
课题二:Node.js那些事儿
课题二:Node.js那些事儿课题二:Node.js那些事儿
课题二:Node.js那些事儿
 
A brief introduction to Machine Learning
A brief introduction to Machine LearningA brief introduction to Machine Learning
A brief introduction to Machine Learning
 
How to ASP.NET MVC4
How to ASP.NET MVC4How to ASP.NET MVC4
How to ASP.NET MVC4
 
Build line notify bot by lotify and create client library by swagger 20200527
Build line notify bot by lotify and create client library by swagger 20200527Build line notify bot by lotify and create client library by swagger 20200527
Build line notify bot by lotify and create client library by swagger 20200527
 
Ruby 的快与慢
Ruby 的快与慢Ruby 的快与慢
Ruby 的快与慢
 
開發環境建置
開發環境建置開發環境建置
開發環境建置
 
從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用從軟體開發角度
談 Docker 的應用
從軟體開發角度
談 Docker 的應用
 

Rails 初探