SlideShare a Scribd company logo
1 of 21
Download to read offline
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

What's hot

Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
Skills Matter
 
App engine beats pony.key
App engine beats pony.keyApp engine beats pony.key
App engine beats pony.key
Alper Çugun
 

What's hot (19)

Sails.js Model / ORM introduce
Sails.js Model / ORM introduceSails.js Model / ORM introduce
Sails.js Model / ORM introduce
 
A Toda Maquina Con Ruby on Rails
A Toda Maquina Con Ruby on RailsA Toda Maquina Con Ruby on Rails
A Toda Maquina Con Ruby on Rails
 
Ruby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter BootstrapRuby on Rails + AngularJS + Twitter Bootstrap
Ruby on Rails + AngularJS + Twitter Bootstrap
 
Capybara + RSpec - ruby dsl-based web ui qa automation
Capybara + RSpec - ruby dsl-based web ui qa automationCapybara + RSpec - ruby dsl-based web ui qa automation
Capybara + RSpec - ruby dsl-based web ui qa automation
 
Sails js
Sails jsSails js
Sails js
 
SPA using Rails & Backbone
SPA using Rails & BackboneSPA using Rails & Backbone
SPA using Rails & Backbone
 
Consuming REST services with ActiveResource
Consuming REST services with ActiveResourceConsuming REST services with ActiveResource
Consuming REST services with ActiveResource
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Rails course day 6
Rails course day 6Rails course day 6
Rails course day 6
 
Next.js in production by Jasdeep Lalli
Next.js in production by Jasdeep Lalli Next.js in production by Jasdeep Lalli
Next.js in production by Jasdeep Lalli
 
App engine beats pony.key
App engine beats pony.keyApp engine beats pony.key
App engine beats pony.key
 
Big Data DC - BenchPress
Big Data DC - BenchPressBig Data DC - BenchPress
Big Data DC - BenchPress
 
Drupal8 + AngularJS
Drupal8 + AngularJSDrupal8 + AngularJS
Drupal8 + AngularJS
 
Building an API in Node with HapiJS
Building an API in Node with HapiJSBuilding an API in Node with HapiJS
Building an API in Node with HapiJS
 
Next.js (almost) in production
Next.js (almost) in productionNext.js (almost) in production
Next.js (almost) in production
 
Capybara with Rspec
Capybara with RspecCapybara with Rspec
Capybara with Rspec
 
Hybrid webinar
Hybrid webinarHybrid webinar
Hybrid webinar
 
Be Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - EcosystemBe Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - Ecosystem
 
RoR 101: Session 6
RoR 101: Session 6RoR 101: Session 6
RoR 101: Session 6
 

Similar to RoR vs-nodejs-by-jcskyting

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

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

Recently uploaded

electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
benjamincojr
 

Recently uploaded (20)

Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
 
Augmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptxAugmented Reality (AR) with Augin Software.pptx
Augmented Reality (AR) with Augin Software.pptx
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdf
 
analog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxanalog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptx
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, Functions
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptx
 
The Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptxThe Entity-Relationship Model(ER Diagram).pptx
The Entity-Relationship Model(ER Diagram).pptx
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdf
 
Circuit Breakers for Engineering Students
Circuit Breakers for Engineering StudentsCircuit Breakers for Engineering Students
Circuit Breakers for Engineering Students
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
 
Insurance management system project report.pdf
Insurance management system project report.pdfInsurance management system project report.pdf
Insurance management system project report.pdf
 
History of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & ModernizationHistory of Indian Railways - the story of Growth & Modernization
History of Indian Railways - the story of Growth & Modernization
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference Modal
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdf
 

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 健保卡註記器捐意願、安寧意願」 在法律上,再⾒見⼿手札是沒有法律效⼒力的 然⽽而實務上,醫院、醫師皆會以家屬意願為主(⽽而⾮非以健保卡註記為 主,⽣生⼈人不可得罪..) 因此健保卡註記就只剩下意願傳達的功能了…(沒辦法,你無法彈起 來告醫師違背你的⽣生前意願) 既然只是意願傳達,那就不需要這麼⿇麻煩了,動兩下⼿手指,讓「再 ⾒見⼿手札」幫你搞定吧~!!