WDI Day Eighteen: Bootstrap and Active Record

We started off with a mini lesson in Bootstrap, which was mainly a review for me since I’ve used it a number of times for my day job. I did learn a few things about the JavaScript functions that are included in Bootstrap, like Affix and Scrollspy, which are definitely a couple of things I should look into more.

The rest of the day we delved into Active Record which was actually a lot of fun, where we learned about object-relational mapping. We played around with making queries and setting up new databases. Setting up Active Record does involve a number of steps that are somewhat confusing like putting together the models and database connections. In general it was pretty interesting seeing how to set up database schemas and seeding the databases.

We used AR to perform CRUD actions that include create, new, save, all, find, find_by, where, update, and destroy. I learned about how to connect to the database with postresql in order to actually get the queries to work. And the instructors discussed how convention is more important than configuration, and the conventions are a bit odd, it will take some time to get used to which ones are singular, plural, snake case, and camel case. Here’s an overview of the conventions covered:

  • Model file names are singular and snake case
  • Model class names are singular and camel case
  • Database schema is plural

Overview of the methods covered:

  • Class methods include all, new, first, last, and find
  • Instance methods include attr_accessors, destroy, save, and update

Leave a Reply