Agile Web Development with Rails (for 3.1) @LVRUG - Jeremy Woertink Ya, that book
Agile Web Developmentwith Rails (for 3.1)
@LVRUG - Jeremy Woertink
Ya, that book
What is "Rails" you ask?
"Ruby on Rails is a framework that makes it easier to develop, deploy, and maintain web applications."
"Rails applications are written in Ruby, a modern, object-oriented scripting language."
•Web Development Framework•MVC Architecture•Written in Ruby•Convention over Configuration•RESTful•Agile•Clean
more info given in the Introduction section
What is "Rails" you ask?
Who uses it?
Websites on Rails•Yellow Pages•Groupon•Living Social•Github•Funny or Die!•Pololu•Cardplayer•ScripSmart•and lots of Russ's pr0n....
Where's the start button?
Installation
You're in luck, it's a gem! :)
$ sudo gem install rails
sudo may not be needed...
Checklist•Know what it is? CHECK
Checklist•Know what it is? CHECK•Know who uses it? CHECK
Checklist•Know what it is? CHECK•Know who uses it? CHECK•Know where to get it? CHECK
Checklist•Know what it is? CHECK•Know who uses it? CHECK•Know where to get it? CHECK•Know how to use it? NOPE. Chuck Testa
Gettin' REAL dirty
$ cd websiteswebsites$ rails new demo create lots of stuff run bundle install Fetching source index for http://rubygems.org/ Your bundle is complete!
websites$ cd demodemo$ rails server=> Booting WEBrick => Rails 3.1.0 application starting in development on http://0.0.0.0:3000
http://localhost:3000
Hello, Rails!
demo$ rails generate controller Say hello goodbye create more stuff... invoke things route whatever
Hello, Rails!
demo$ rails generate controller Say hello goodbye create more stuff... invoke things route whatever
Visit http://localhost:3000/say/hello
ZOMG! What happened?
•created "SayController"•app/controllers/say_controller.rb
•created views for "say"•app/views/say/hello.html.erb•app/views/say/goodbye.html.erb
•updated routes with "say" routes•config/routes.rb
•created other super secret squirrel stuff (i.e. assets, tests, helper)
app/controllers/say_controller.rb
class SayController < ApplicationController def hello end
def goodbye end
end
app/controllers/say_controller.rb
app/views/say/hello.html.erb
• say - The name of the controller• hello - The name of the action• html - The end format we want• js, xml, text...
• erb - The ruby templating system• haml, slim, mustache, liquid...
app/views/say/hello.html.erb
<h1>Say#hello</h1><p>Find me in app/views/say/hello.html.erb</p>
app/views/say/hello.html.erb
<h1>Hello from Rails!</h1><p>It is now <%= Time.now %></p>
http://localhost:3000/say/hello
app/controllers/say_controller.rb
class SayController < ApplicationController def hello @time = Time.now end
def goodbye end
end
app/views/say/hello.html.erb
<h1>Hello from Rails!</h1><p>It is now <%= @time %></p>
Fancy pants time!
app/views/say/hello.html.erb
<h1>Hello from Rails!</h1><p>It is now <%= @time %></p><p> Time to say <%= link_to("Goodbye", say_goodbye_path) %>!</p>
http://localhost:3000/say/hello
app/views/say/goodbye.html.erb
<h1>Say#goodbye</h1><p>Find me in app/views/say/goodbye.html.erb</p>
app/views/say/goodbye.html.erb
<h1>Beer time?</h1><blink>Holla atchya boy!</blink><span>Say<%= link_to("Hello", say_hello_path) %> again.</span>
app/views/say/goodbye.html.erb
<h1>Beer time?</h1><blink>Holla atchya boy!</blink><span>Say<%= link_to("Hello", say_hello_path) %> again.</span>
ahh yeah, you love the blink tag don't ya!
Recapitulation time!
• Installed rails• Created a new application• Generated controller and views• Added dynamic content• Linked pages together
Questions?!