SlideShare a Scribd company logo
Rails vs Node.js
2015.09.17
⺩王信凱 Sky
FB: jcsky.wang
Ruby on Rails: 6 months
Node.js: 1 week / 1 project
內容如有錯誤資訊請來信指正
jcskyting@gmail.com
WHY~?!
• Ruby on Rails: 想開發網站,AlphaCamp ihower
• Node.js: front-end interview (javascript, full-stack)
Rails vs Node.js
Ruby
Rails
Rails server engine /
event driven gem
include many many
CRUD / DataBase / safe
sync
javascript
express / koa / sails ..
node.js

npm any you want
speed / realtime / anyway
you want
async
Rails vs Node.js
Node.js is not framework..
express / koa / hapi / sails
Rails vs Node.js
• javascript 不會報錯誤,不易 Debug (chrome console )
Rails vs Node.js
• Node.js 沒有 server log,不易 Debug
Rails error
Rails vs Node.js
• Rails console debug
Rails vs Node.js
• 透過 Rails method,換 database 不必改 code
• 優點: 開發快、不爽就換 DB
• 缺點: 對DataBase的個別特性瞭解有限、不熟悉
Event.joins(:category)
# SELECT "events".* FROM "events" INNER JOIN "categories" ON "categories"."id" =
"events"."category_id"
Event.includes(:category, :attendees)
# SELECT "events".* FROM "events"
# SELECT "categories".* FROM "categories" WHERE "categories"."id" IN (1,2,3...)
# SELECT "attendees".* FROM "attendees" WHERE "attendees"."event_id" IN (4, 5, 6,
7, 8...)
Rails vs Node.js
• not only Ruby, numerous Rails helper method
html 重覆使⽤用
<%= render :partial => 'form', :locals => { :f => f } %>
form
<%= form_for @event, :url => { :controller => 'events', :action =>
'update', :id => @event } do |f| %>
<%= f.textarea :description, :class=>”w100p”, :rows =>10 %>
<%= f.submit "Update" %>
<% end %>
controller method 重覆使⽤用
before_action :set_event, :only => [ :show, :edit, :update, :destroy]
session read/write
session[:hahaha]
Rails vs Node.js
• Rails have some Security Design (實戰聖經)
跨站偽造請求CSRF(Cross-site request forgery)
Rails內建了CSRF防禦功能,也就是所有的POST請求,都必須加上⼀一個安全驗證碼
HTML:
<input type="hidden" name="authenticity_token" value="zFGT
+TiykMj7Tsip3sY5G7iELupGD3BttZ8x6F2diThGOVH9+nEoXxkeLOhuLx9kGaWRoOh
ZuwY+OXzXU3EevA==">
Parameters:
{"utf8"=>"✓", "authenticity_token"=>"HC4eVH/
wdojRqSJFk8xYdobZPByVTFkh2WiCbK6HYb+WRtxQvTPOHzP5xgQjJX4JJ/
iDVjsakkpSzs9ToGv2Ow==", "issue"=>{"title"=>"yaya", "description"=>"what the
fuck"}, "commit"=>"建⽴立議題"}
Rails vs Node.js
• Rails have some Security Design(實戰聖經)
跨站腳本攻擊XSS(Cross-Site Scripting)
惡意的使⽤用者可以將惡意的Script放在網⾴頁上讓其他使⽤用者執⾏行
要防範這個問題的⽅方法,就是要逸出使⽤用者輸⼊入的內容,例如將<script>變成
&lt;script&gt;,使之顯⽰示出來的時候不讓瀏覽器去執⾏行,Rails預設全部逸出
若要開放讓使⽤用者可以張貼簡單的HTML內容,使⽤用⽩白名單功能
Rails vs Node.js
• Rails have some Security Design(實戰聖經)
log敏感資訊過濾(預設)
Processing UsersController#create (for 127.0.0.1 at 2009-01-02 11:02:33) [POST]
Parameters: {"user"=>{"name"=>"susan",
"password_confirmation"=>"[FILTERED]", "password"=>"[FILTERED]"},
"commit"=>"Register", "action"=>"create",
"authenticity_token"=>"9efc03bcc37191d8a6dc3676e2e7890ecdfda0b5",
"controller"=>"users"}
Ruby vs javascript
gem vs npm
• 什麼~?!! npm.count ⽐比較多!!
Rails intro
MVC
Model-View-Control
route.rb
HTTP request
GET /users/1
Browser
UsersController
end
def show
@user = User.find(params[:id])
respond_to do |format|
format.html
format.xml
end
end
def index
......
end
Model
Database
#show.html.erb
<html>
<h1>User Profile</h1>
<p><%= @user.nickname %></p>
</html>
View
Controller Action
Rails intro
Rails ?
• Justin Gehtland Java :Rails = 3.5 : 1
• Proc.net PHP : Rails = 10 : 1
• JavaEye JAVA : Rails = 10 : 1
• thegiive PHP : Rails = 8 : 1
Rails vs Node.js
Ruby
Rails
Rails server engine /
event driven gem
include many many
CRUD / DataBase / safe
javascript
express / koa / sails ..
node.js

npm any you want
speed / realtime /
anyway you want
in the future
Real Time App / Web
再⾒見⼿手札 theword.tw
FB: 再⾒見⼿手札 www.facebook.com/theword.tw
「再⾒見⼿手札 vs 健保卡註記器捐意願、安寧意願」
在法律上,再⾒見⼿手札是沒有法律效⼒力的
然⽽而實務上,醫院、醫師皆會以家屬意願為主(⽽而⾮非以健保卡註記為
主,⽣生⼈人不可得罪..)
因此健保卡註記就只剩下意願傳達的功能了…(沒辦法,你無法彈起
來告醫師違背你的⽣生前意願)
既然只是意願傳達,那就不需要這麼⿇麻煩了,動兩下⼿手指,讓「再
⾒見⼿手札」幫你搞定吧~!!

More Related Content

PDF
RoR vs-nodejs-by-jcskyting
PDF
AngularJS meets Rails
PDF
How angularjs saves rails
PDF
アドテク×Scala @Dynalyst
PDF
CloudFormation experience
PDF
Marrying angular rails
PDF
Intro to Sails.js
KEY
Capybara
RoR vs-nodejs-by-jcskyting
AngularJS meets Rails
How angularjs saves rails
アドテク×Scala @Dynalyst
CloudFormation experience
Marrying angular rails
Intro to Sails.js
Capybara

What's hot (19)

PDF
Sails.js Model / ORM introduce
ODP
A Toda Maquina Con Ruby on Rails
PPTX
Ruby on Rails + AngularJS + Twitter Bootstrap
PPTX
Capybara + RSpec - ruby dsl-based web ui qa automation
PPT
PDF
Consuming REST services with ActiveResource
PPTX
SPA using Rails & Backbone
PDF
Primefaces Nextgen Lju
PDF
Rails course day 6
PDF
Next.js in production by Jasdeep Lalli
ZIP
App engine beats pony.key
PPT
Big Data DC - BenchPress
PDF
Drupal8 + AngularJS
PPTX
Building an API in Node with HapiJS
PDF
Next.js (almost) in production
PDF
Capybara with Rspec
PDF
Hybrid webinar
PDF
Be Happy With Ruby on Rails - Ecosystem
ODP
RoR 101: Session 6
Sails.js Model / ORM introduce
A Toda Maquina Con Ruby on Rails
Ruby on Rails + AngularJS + Twitter Bootstrap
Capybara + RSpec - ruby dsl-based web ui qa automation
Consuming REST services with ActiveResource
SPA using Rails & Backbone
Primefaces Nextgen Lju
Rails course day 6
Next.js in production by Jasdeep Lalli
App engine beats pony.key
Big Data DC - BenchPress
Drupal8 + AngularJS
Building an API in Node with HapiJS
Next.js (almost) in production
Capybara with Rspec
Hybrid webinar
Be Happy With Ruby on Rails - Ecosystem
RoR 101: Session 6
Ad

Similar to RoR vs-nodejs-by-jcskyting (20)

PDF
Integrating React.js Into a PHP Application
PDF
AWS meets Continuous Delivery
PDF
Node.js vs Play Framework
KEY
Server side scripting smack down - Node.js vs PHP
PPTX
JavaScript on the server - Node.js
PPT
Ruby on Rails workshop for beginner
PPT
Ruby On Rails
PPTX
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
PDF
What’s new in Java SE, EE, ME, Embedded world & new Strategy
PDF
Connecting the Worlds of Java and Ruby with JRuby
PPTX
StrongLoop Overview
PDF
Crash Course HTML/Rails Slides
KEY
Ruby on Rails survival guide of an aged Java developer
PPT
JavaScript Basics with baby steps
KEY
HTML 5 & CSS 3
PDF
SproutCore and the Future of Web Apps
PPT
Static Code Analysis For Ruby
PPTX
Real World Lessons on the Pain Points of Node.JS Application
PDF
Developing realtime apps with Drupal and NodeJS
KEY
Wider than rails
Integrating React.js Into a PHP Application
AWS meets Continuous Delivery
Node.js vs Play Framework
Server side scripting smack down - Node.js vs PHP
JavaScript on the server - Node.js
Ruby on Rails workshop for beginner
Ruby On Rails
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
What’s new in Java SE, EE, ME, Embedded world & new Strategy
Connecting the Worlds of Java and Ruby with JRuby
StrongLoop Overview
Crash Course HTML/Rails Slides
Ruby on Rails survival guide of an aged Java developer
JavaScript Basics with baby steps
HTML 5 & CSS 3
SproutCore and the Future of Web Apps
Static Code Analysis For Ruby
Real World Lessons on the Pain Points of Node.JS Application
Developing realtime apps with Drupal and NodeJS
Wider than rails
Ad

Recently uploaded (20)

PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
composite construction of structures.pdf
PPTX
Artificial Intelligence
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPT
Project quality management in manufacturing
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Lecture Notes Electrical Wiring System Components
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
Construction Project Organization Group 2.pptx
PDF
Digital Logic Computer Design lecture notes
Foundation to blockchain - A guide to Blockchain Tech
composite construction of structures.pdf
Artificial Intelligence
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Internet of Things (IOT) - A guide to understanding
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
UNIT-1 - COAL BASED THERMAL POWER PLANTS
CYBER-CRIMES AND SECURITY A guide to understanding
R24 SURVEYING LAB MANUAL for civil enggi
Project quality management in manufacturing
Embodied AI: Ushering in the Next Era of Intelligent Systems
CH1 Production IntroductoryConcepts.pptx
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Lecture Notes Electrical Wiring System Components
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Construction Project Organization Group 2.pptx
Digital Logic Computer Design lecture notes

RoR vs-nodejs-by-jcskyting

  • 2. ⺩王信凱 Sky FB: jcsky.wang Ruby on Rails: 6 months Node.js: 1 week / 1 project 內容如有錯誤資訊請來信指正 jcskyting@gmail.com
  • 3. WHY~?! • Ruby on Rails: 想開發網站,AlphaCamp ihower • Node.js: front-end interview (javascript, full-stack)
  • 4. Rails vs Node.js Ruby Rails Rails server engine / event driven gem include many many CRUD / DataBase / safe sync javascript express / koa / sails .. node.js
 npm any you want speed / realtime / anyway you want async
  • 5. Rails vs Node.js Node.js is not framework.. express / koa / hapi / sails
  • 6. Rails vs Node.js • javascript 不會報錯誤,不易 Debug (chrome console )
  • 7. Rails vs Node.js • Node.js 沒有 server log,不易 Debug
  • 9. Rails vs Node.js • Rails console debug
  • 10. Rails vs Node.js • 透過 Rails method,換 database 不必改 code • 優點: 開發快、不爽就換 DB • 缺點: 對DataBase的個別特性瞭解有限、不熟悉 Event.joins(:category) # SELECT "events".* FROM "events" INNER JOIN "categories" ON "categories"."id" = "events"."category_id" Event.includes(:category, :attendees) # SELECT "events".* FROM "events" # SELECT "categories".* FROM "categories" WHERE "categories"."id" IN (1,2,3...) # SELECT "attendees".* FROM "attendees" WHERE "attendees"."event_id" IN (4, 5, 6, 7, 8...)
  • 11. Rails vs Node.js • not only Ruby, numerous Rails helper method html 重覆使⽤用 <%= render :partial => 'form', :locals => { :f => f } %> form <%= form_for @event, :url => { :controller => 'events', :action => 'update', :id => @event } do |f| %> <%= f.textarea :description, :class=>”w100p”, :rows =>10 %> <%= f.submit "Update" %> <% end %> controller method 重覆使⽤用 before_action :set_event, :only => [ :show, :edit, :update, :destroy] session read/write session[:hahaha]
  • 12. Rails vs Node.js • Rails have some Security Design (實戰聖經) 跨站偽造請求CSRF(Cross-site request forgery) Rails內建了CSRF防禦功能,也就是所有的POST請求,都必須加上⼀一個安全驗證碼 HTML: <input type="hidden" name="authenticity_token" value="zFGT +TiykMj7Tsip3sY5G7iELupGD3BttZ8x6F2diThGOVH9+nEoXxkeLOhuLx9kGaWRoOh ZuwY+OXzXU3EevA=="> Parameters: {"utf8"=>"✓", "authenticity_token"=>"HC4eVH/ wdojRqSJFk8xYdobZPByVTFkh2WiCbK6HYb+WRtxQvTPOHzP5xgQjJX4JJ/ iDVjsakkpSzs9ToGv2Ow==", "issue"=>{"title"=>"yaya", "description"=>"what the fuck"}, "commit"=>"建⽴立議題"}
  • 13. Rails vs Node.js • Rails have some Security Design(實戰聖經) 跨站腳本攻擊XSS(Cross-Site Scripting) 惡意的使⽤用者可以將惡意的Script放在網⾴頁上讓其他使⽤用者執⾏行 要防範這個問題的⽅方法,就是要逸出使⽤用者輸⼊入的內容,例如將<script>變成 &lt;script&gt;,使之顯⽰示出來的時候不讓瀏覽器去執⾏行,Rails預設全部逸出 若要開放讓使⽤用者可以張貼簡單的HTML內容,使⽤用⽩白名單功能
  • 14. Rails vs Node.js • Rails have some Security Design(實戰聖經) log敏感資訊過濾(預設) Processing UsersController#create (for 127.0.0.1 at 2009-01-02 11:02:33) [POST] Parameters: {"user"=>{"name"=>"susan", "password_confirmation"=>"[FILTERED]", "password"=>"[FILTERED]"}, "commit"=>"Register", "action"=>"create", "authenticity_token"=>"9efc03bcc37191d8a6dc3676e2e7890ecdfda0b5", "controller"=>"users"}
  • 16. gem vs npm • 什麼~?!! npm.count ⽐比較多!!
  • 17. Rails intro MVC Model-View-Control route.rb HTTP request GET /users/1 Browser UsersController end def show @user = User.find(params[:id]) respond_to do |format| format.html format.xml end end def index ...... end Model Database #show.html.erb <html> <h1>User Profile</h1> <p><%= @user.nickname %></p> </html> View Controller Action
  • 18. Rails intro Rails ? • Justin Gehtland Java :Rails = 3.5 : 1 • Proc.net PHP : Rails = 10 : 1 • JavaEye JAVA : Rails = 10 : 1 • thegiive PHP : Rails = 8 : 1
  • 19. Rails vs Node.js Ruby Rails Rails server engine / event driven gem include many many CRUD / DataBase / safe javascript express / koa / sails .. node.js
 npm any you want speed / realtime / anyway you want
  • 20. in the future Real Time App / Web
  • 21. 再⾒見⼿手札 theword.tw FB: 再⾒見⼿手札 www.facebook.com/theword.tw 「再⾒見⼿手札 vs 健保卡註記器捐意願、安寧意願」 在法律上,再⾒見⼿手札是沒有法律效⼒力的 然⽽而實務上,醫院、醫師皆會以家屬意願為主(⽽而⾮非以健保卡註記為 主,⽣生⼈人不可得罪..) 因此健保卡註記就只剩下意願傳達的功能了…(沒辦法,你無法彈起 來告醫師違背你的⽣生前意願) 既然只是意願傳達,那就不需要這麼⿇麻煩了,動兩下⼿手指,讓「再 ⾒見⼿手札」幫你搞定吧~!!