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.
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.
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.
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.
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
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
- 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!