TECHTalk:
Ruby on Rails

What is Ruby?

  • Programming language
  • Object-oriented
  • Dynamic/duck typing
  • Package/library management via RubyGems
  • Many compiler implementations including JIT and pre-compiling
  • IRB, a REPL for Ruby
  • Focused on programmer productivity and enjoyment: ...we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. [Machines] are the slaves.

    Yukihiro "Matz" Matsumoto, creator of Ruby

  • Open source
  • Awesome

What is Rails?

  • Ruby framework
    • Rails:Ruby::CodeIgniter:PHP
    • Rails:Ruby::Wicket:Java
    • Rails:Ruby::Django:Python
  • "Convention over configuration"
  • MVC
  • ORM (ActiveRecord)
  • Routing
  • RESTful
  • Massive developer community (if you want to do a thing, there's probably a gem for it)
  • Open source
  • Also awesome

The ubiquitous Rails demo: Let's build an app!

Feedback: The Web App

Step-by-step

  1. Application architecture (it ain't gonna plan itself)
  2. Lay the groundwork
  3. Generate resources
  4. Fix funky output in the generated code
  5. Make it usable
  6. Tell us when we get feedback
  7. Deploy it to Heroku

Resources

  1. Install Rails gem via RubyGems:
    gem install rails --no-ri --no-rdoc
  2. Generate a new Rails project:
    rails new .
  3. Add rails-haml gem to our Gemfile and install it:
    bundle install
  1. Generate a RESTful resource for users:
    rails g scaffold User name:string email:string
  2. Generate a RESTful resource for feedback submissions:
    rails g scaffold Submission user:references body:text
  3. Migrate the database to build the necessary tables:
    rake db:migrate
  1. Change the User reference to a dropdown list in the Submission form.
  2. Change User#index and User#show to display User.name instead of just User.
  1. Add navigation.
  2. Add per-user submission lists.
  1. Configure ActionMailer defaults for :development group.
  2. Generate an ActionMailer:
    rails g mailer SubmissionMailer
  3. Create submission notification method.
  4. Create submission notification view.
  5. Implement submission notification on SubmissionController#create.
  1. Move sqlite3 gem to :development group and add pg (postgres) gem to the :production group.
  2. Update your Gemfile.lock file:
    bundle install
  3. Create a new Heroku app:
    heroku apps:create tech-talks-feedback
  4. Configure Heroku to use SendGrid to send our notifications and update :production group ActionMailer defaults:
    heroku addons:add sendgrid:starter
  5. Push your app to Heroku:
    git push heroku master
  6. Run the database migrations:
    heroku run bundle exec rake db:migrate

Thanks for participating!

The source files for this project are available at github.com/chrislambe/tech-talk-rails. This presentation can be found at chrislambe.github.io/tech-talk-rails.

This presentation was assembled with the magic of impress.js. Nerd.

If you'd like you can send me any feedback via the app we just built! For the record it can be found at tech-talks-feedback.herokuapp.com

Additional resources:

RailsCasts: railscasts.com

Rails Guides: guides.rubyonrails.org

Rails API: api.rubyonrails.org

Eloquent Ruby: amazon.com/Eloquent-Ruby-Addison-Wesley-Professional/dp/0321584104

  1. Application architecture (it ain't gonna plan itself)
  2. Lay the groundwork
  3. Generate resources
  4. Fix funky output in the generated code
  5. Make it usable
  6. Tell us when we get feedback
  7. Deploy it to Heroku