Looking for more to read? Check out the Archives!

Positit!

The second course at Tealeaf delved into Ruby on Rails development, from the ground up. Most tutorials and guides that I’ve seen include either scaffolding, or at least using generators, as shortcuts for building apps, (not to mention, lots of gems). There’s nothing wrong with using shortcuts, but we built everything ourselves, because it helps us learn how Rails works. The only generators we used were for migrations, but we still wrote the migation files.

For example, this terminal command:

1 小A曰: rails g migration CreateUsers

Produces this file:

1 class CreateUsers < ActiveRecord::Migration
2   def change
3     create_table :users do |t|
4 
5     end
6   end
7 end

Creating the table is simply a matter of declaring the data type (for example, string or integer), and the row names (lines 4 and 5):

1 class CreateUsers < ActiveRecord::Migration
2   def change
3     create_table :users do |t|
4       t.string :username, :email, :phone_number, :password_digest
5       t.timestamps
6     end
7   end
8 end

The main project for the second course was “Postit”, a Reddit-style application. While the app itself has a simple and clean UI, it has a fair amount of complexity under the hood.

I learned several fundamental aspects of Rails development, by incorporating the following features:

  • Ruby 2 and Rails 4
  • Model-backed forms
  • Using Ajax to vote
  • URL Slugs
  • Authentication
  • Custom time zone display
  • Admin roles

I also produced a static ‘About’ page, and I implemented two-factor authentication, using the TWilio API. However, I have not yet pushed the two-factor authentication into production yet, because I wanted to learn more about how to protect my API key and account information. I experimented with the Figaro gem, but this will be a major part of the third, and final course of the program, so I will revisit that soon.

Please feel free to create a user account, and share a link or comment, and vote on other posts and comments.

Take Postit! for a Spin


If you enjoyed this post, you might want to subscribe, so you don't miss the next one!