Ruby on Rails [ Ruby On Rails.ppt ] - [Ruby - [Ruby-Doc.org ...
Happy Coding with Ruby on Rails
-
Upload
ochirkhuyag-lkhagva -
Category
Technology
-
view
2.726 -
download
0
description
Transcript of Happy Coding with Ruby on Rails
![Page 1: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/1.jpg)
Happy Coding with
Ruby on RailsMaahai L.Ochirkhuyag
2009-6-6 @MAJ Meeting, Tokyo
![Page 2: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/2.jpg)
Ochirkhuyag.is_who?
ochko.blogspot.commaaxai.blogspot.com
2000~ programming2005~ USI Inc.
2008~2010 Waseda Univ. Master's course
2007~ Ruby & RoR
![Page 3: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/3.jpg)
Ruby
“more powerful than Perl, and more OO than Python”
“interpreted, object-oriented, portable, untyped, garbage collected”
![Page 4: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/4.jpg)
“Often people, especially computer engineers, focus on the machines. They think, "By doing this, the machine will run faster. By doing this, the machine will run more effectively. By doing this, ... But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves.”
Yukihiro ‘Matz’ Matsumoto, creator of Ruby:
![Page 5: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/5.jpg)
Everything is Object
>> 2009.class # → Fixnum
>> :lets_start.class # → Symbol
>> "ruby is sucking".capitalize
# → "Ruby is sucking"
>> 3.times {puts "Сайн уу?"}
Сайн уу?
Сайн уу?
Сайн уу?
![Page 6: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/6.jpg)
Ruby array is Powerful
>> a = [ 1, 2, 3, 'four', 'V', nil, 2 ]
=> [1, 2, 3, "four", "V", nil, 2]
>> a.compact.uniq
=> [1, 2, 3, "four", "V"]
>> [1, 2, 3, 4, 5, 6].select { |e| e % 2 == 0 }
=> [2, 4, 6]
>> [1, 2, 3, 4].inject(0) { |res, el| res + el }
=> 10
![Page 7: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/7.jpg)
Ruby classes are Open
# Numeric is ruby's built-in class
# We can add a method to it
class Numeric
def plus(x)
self.+(x)
end
end
5.plus 6 # → 11
![Page 8: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/8.jpg)
Block is Expressive
search_engines =
%w[Google Yahoo MSN].map do |engine|
"http://www." + engine.downcase + ".com"
end
# → [ "http://www.google.com",
"http://www.yahoo.com",
"http://www.msn.com" ]
![Page 9: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/9.jpg)
Built-in Regular expression
//.class
# → Regexp
a = "the quick brown fox"
a =~ /q[uia]*ck/
# → 4
a.gsub(/[aeiou]/, '*')
# → "th* q**ck br*wn f*x"
![Page 10: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/10.jpg)
Mixin
class MyArray
include Enumerable
# implement each
end
m = MyArray.new()
m << 1 << 2 << 3
m.find{|e| e % 2 == 0}
# → 2
![Page 11: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/11.jpg)
try ruby! (in your browser)
http://tryruby.hobix.com/
![Page 12: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/12.jpg)
![Page 13: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/13.jpg)
David ‘dhh’ Heinemeier Hansson,creator of Ruby on Rails
● Convention over Configuration
● DRY● High Productivity
![Page 14: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/14.jpg)
Websites on Rails
![Page 15: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/15.jpg)
Ruby on Rails vs...
Java Python PHP Ruby
etc. etc. etc. etc.
![Page 16: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/16.jpg)
MVC Architecture
![Page 17: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/17.jpg)
![Page 18: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/18.jpg)
Convention overConfiguration
CoC
![Page 19: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/19.jpg)
![Page 20: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/20.jpg)
![Page 21: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/21.jpg)
![Page 22: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/22.jpg)
![Page 23: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/23.jpg)
![Page 24: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/24.jpg)
![Page 25: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/25.jpg)
![Page 26: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/26.jpg)
![Page 27: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/27.jpg)
![Page 28: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/28.jpg)
![Page 29: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/29.jpg)
![Page 30: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/30.jpg)
http://app/weblog/app/views/weblog
![Page 31: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/31.jpg)
http://app/weblog/show/9/app/views/weblog/show.rhtml
![Page 32: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/32.jpg)
Don't Repeat Yourself(DRY)
![Page 33: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/33.jpg)
Productivity Motivation ← ←Happiness Beautiful Code←
![Page 34: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/34.jpg)
Happy Coding Demo
![Page 35: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/35.jpg)
Q&A
?
if you.want? contact_me_by {:twitter => ochko,:github => ochko }
![Page 36: Happy Coding with Ruby on Rails](https://reader030.fdocuments.in/reader030/viewer/2022020123/5593ae3d1a28ab993f8b4729/html5/thumbnails/36.jpg)
References● http://marklunds.com/rails101
● http://www.slideshare.net/Joopp/ruby-on-rails-presentation-presentation
● http://media.rubyonrails.org/presentations/programminghappiness.pdf
● http://media.rubyonrails.org/video/rails_blog_2.mov