10. There’s a Gem for That
• Wait, there isn’t?
• Write your own and publish
• > gem install rails
> rails new my_sweet_app
> cd my_sweet_app
> rails s
> open http://0.0.0.0:3000/
• You now have the beginnings of a web application
• http://rubygems.org/
15. Too Silly To Be Real
• Just kidding
• Crazy language flexibility
• class Fixnum
def to_kittens
return to_s << “ kitten” if abs == 1
to_s << “ kittens”
end
end
• 5.to_kittens => “5 kittens”
• -1.to_kittens => “-1 kitten”
17. Actually...
• In ruby, they’re called blocks
• Enumerators (Loops)
• 42.times do
p “What is the meaning of life?”
end
• [ 1 , 2 , 3 ].each do |i|
p i.to_kittens
end
28. Heroku
• We’ll need to setup a few more things
• Gemfile
• Procfile
• Git repo
29. Gemfile
• Tells heroku which gems we’ll need
• > gem install bundler
• Add a file called Gemfile (capital G is important)
with the following contents...
source :rubygems
gem “sinatra”
gem “heroku”, :group => :development
• > bundle
30. Procfile
• Tells heroku how to boot our web app
• Add a file called Procfile (capital P is
important) with the following contents...
web: ruby -rubygems hi.rb -p $PORT
31. Git Repo
• Run the following in your terminal
• > git init
> git add .
> git commit -m “my first git commit!”
32. Heroku Again
• Sign Up - http://heroku.com
• > heroku apps:create --stack=cedar
> git push heroku master
> heroku open
• If your heroku commands aren’t working,
try prepending them with “bundle exec” e.g.
> bundle exec heroku open