More Related Content
Similar to 遇見 Ruby on Rails
Similar to 遇見 Ruby on Rails (20)
More from Wen-Tien Chang (20)
遇見 Ruby on Rails
- 2. Agenda
• Who am I
• My story about web development
• Introduction to Rails
• Rails on Rails live demo
• Why Ruby?
- 3. Who am I?
• (a.k.a. ihower)
•
• & ( )
• Ruby on Rails (since 2006)
- 16. CGI, Perl
HTML
#!/usr/bin/perl
open(FILE, "count.txt");
$num = <FILE>; $num++;
close (FILE);
open(WRITETO, ">count.txt");
print WRITETO "$num";
close (WRITETO);
print <<PRINTAREA;
content-type:text/htmlnn
<style>
<!--
body {background-color: black; line-height:1;
margin-top: 0cm;
margin-left: 0cm;
margin-right: 0cm}
--></style>
<body><center>
<b><font size=1 color=white>
$num</font></b>
PRINTAREA
- 18. PHP
HTML
<?php
$counter = intval(file_get_contents("counter.dat")) + 1;
$fp = fopen("counter.dat", "w");
fwrite($fp, $counter);
fclose($fp);
?>
<p>Visitors: <?php echo @counter %></p>
- 19. PHP & MySQL
<?php
$db = mysql_connect("localhost", "root", "password");
mysql_query("SET NAMES 'utf8'");
mysql_select_db($SERVER['db']);
?>
<html>
<?
$sql="select * from news where Class='1' or Class='3' order by CTDate desc
limit 0,5";
$result= mysql_query($sql);
while ( $arr=mysql_fetch_array($result) ) {
echo <<<NEWSEND
<div class="box">
<span class="box-title-1"> <b> $arr[Title] </b> $arr[CTDate] </span>
<div class="box-content">
$arr[Text]
</div>
</div>
NEWSEND;
}
?>
</html>
- 22. 2005
• PHP web framework
•
- 24. MVC
•
Model Controller View
• Model
•
• View
• Ruby HTML
• Controller Model
• (e.g. ) Request Model View (e.g. HTML)
- 25. 1.
Controller
2.
3.
4.
View Model
DB
- 26. MVC?
•
•
(DRY: Don’t repeat yourself)
•
- 27. ORM
• Object-relational mapping
•
@posts = Post.find(:all, :order => "id desc", :limit => 5 )
@posts.each do |post|
...
end
- 30. Rails?
• ( MIT ) Web
database-backed
• MVC (Model-View-Control )
• ( ) Ruby
Ajax ORM (object-relational-mapping)
• 2004 David Heinemeier Hanson(DHH)
37signals
- 31. • Ruby
• Don’t Repeat Yourself (DRY) •
• Convention Over Configuration
•
•
•
- 33. Rails
• 2005 DHH Hacker
• 2006 Rails Jolt
• 2005~2006 Ruby/Rails
1552%
• Ruby Tiobe
26 11
- 34. Rails ?
Java(Spring/Hibernate) Rails
4 20 4 ( 5 )
3293 1164
1161 113
/ 62/549 55/126
Justin Gehtland Java
Rails
- 35. Rails ?
• Justin Gehtland Java :Rails = 3.5 : 1
• Proc.net PHP : Rails = 10 : 1
• JavaEye JAVA : Rails = 10 : 1
• thegiive( Rails ) PHP : Rails = 8 : 1
- 37. Rails ?
M
V C
MVC
Model-View-Control
- 41. Ruby?
•
(interpreted)
•
•
• a.k.a. Matz
• Lisp, Perl, Smalltalk
• Happy
- 42. a trivial Ruby example
str = "May Ruby be with you!"
5.times { puts str }
- 44. code lines matters
1. more code more bugs
2. more code needs IDE
3. more code needs more time to read
- 46. • Web framework like Rails has
• MVC
• ORM
• Ruby is
• interpreted scripting language
• dynamic typing language
• object oriented programming
- 47. Rails Ruby
http://ihower.tw/training
- 50. 1. Learn more
programming language
Scripting Language: Ruby, Python, JavaScript
Functional Language: Erlang, Scala, Haskell, Clojure
- 70. • Ruby Tuesday meeting ( )
• RubyConf Taiwan (2010/4/25)
• OSDC.TW (2010/4/24)
• COSCUP (2010/8/14)
• RubyKaigi (2010/8/27 )