Becoming an MVP and how I plotted my eating

I entered the Varvet apprenticeship program after finishing an intense 12-week web developer bootcamp. There I got introduced to Ruby and JavaScript and some of their frameworks, while collaborating in pairs with other students on assignments. On many occasions during the bootcamp I remember saying to myself “Why did I sign up for this?“ (most likely using a dash more profanity). During my apprenticeship, I have realised exactly why I did, the bootcamp gave me basic knowledge about how Ruby on Rails and JavaScript work, while the apprenticeship has made me realise that you do not have to be an expert on Ruby on Rails to be able to do awesome things.

Being a busy mom my spare time is remarkably precious. I wanted to tackle someting that is always an issue in my household and that is the question “What should we have for dinner?“. I also spend too much time going to the store to buy something I forgot on my last trip. With this in mind, my apprenticeship project became an app I call PlotEat. With PlotEat you can store your recipes, create menus with the recipes and from the menu you can create a shopping list with the ingredients you need.

The Process

I approached the project as a real client project with my mentor here at Varvet acting as the product owner who also reviewed and gave me feedback on the code. I used Pivotal Tracker to organise and keep track of all the features that I wanted to implement in my project and I decided on what was an MVP (minimum viable product). I used Ruby on Rails to develop the project, I used Cucumber for acceptance tests, RSpec for unit tests and Rubocop to enforce code formatting. I set up Travis CI for continuous integration, Heroku for continuous deployment and Code climate for test coverage reporting and code quality analysis.

The Challenge

I had to tackle a lot of challenges during this project, one of them concerns Active Record associations. I had created two models, a menu model and a recipe model. They needed to be connected so that a menu could have several recipes, and a recipe should also be able to belong to several menus; a many-to-many relationship. On the first try I added a migration to add a foreign key for menu to recipes, thinking I was on the right track.

20190423092936_add_menu_to_recipe.rb

class AddMenuToRecipe < ActiveRecord::Migration[5.2]
  def change
    add_reference :recipes, :menu, foreign_key: true
  end
end

Realising later that recipes should be added to a menu and that meant I had to remove the early migration. And then I was absolutely sure that a join-table for menus and recipes would be the solution and I was sure I didn’t need a model for this.

20190502191109_create_join_table_menus_recipes.rb

class CreateJoinTableMenusRecipes < ActiveRecord::Migration[5.2]
  def change
    create_join_table :menus, :recipes do |t|
      t.index %i[menu_id recipe_id]
      t.index %i[recipe_id menu_id]
    end
  end
end

Only having to drop it the day after and make a MenuRecipe model instead to change the association from has_and_belongs_to_many to has_many :through.

20190503084229_create_menu_recipes

class CreateMenuRecipes < ActiveRecord::Migration[5.2]
  def change
    create_table :menu_recipes do |t|
      t.references :recipe, index: true, foreign_key: true
      t.references :menu, index: true, foreign_key: true

      t.timestamps null: false
    end
  end
end

What I have gained

During the apprenticeship I have gained better knowledge of:

  • Ruby on Rails
  • Associations and migrations
  • Travis CI
  • Rubocop
  • How to drop a join table

Before starting this apprenticeship I had already had some practice in feeling confused and will continue to feel for some time, no surprise on that front. Compared to the apprenticeship, the bootcamp was intense, it left me stressed that I didn’t know enough while recognising I had gained an enormous amount of knowledge in a short time. Compared to the bootcamp, the first phase of the apprenticeship has been less stressful and has allowed me to clarify what I have learned so far. I have strengthened my foundation which is a real confidence booster. As I enter the final month of my apprenticeship I am excited to start pair programming with the experienced developers here at Varvet, and a little alarmed by the fact that I will be working on client projects. I look forward to learning from everyone here!