The One With a Form

My Happiness Index Dashboard thing has a form now! And it saves stuff!

This morning I had some time to work on my apprenticeship project so I added a post route to add a new entry, a form with 2 text inputs to the template, a controller action to transform these into lists of integers and a function inside my model creates a new struct and inserts it into the database.

I ran into a few problems along the way:

  1. I forgot that since Phoenix 1.4 Router.Helpers is not imported into view/controller anymore but rather aliased as Routes. I checked for typos in my path but couldn’t find any. It took me a while until I found the solution.
  2. I copied some plain HTML from MDN (because I feel like I don’t remember anything when it comes to HTML/CSS/JS) and got an error that I needed to add a CSRF token. I googled around a bit but I guess my mistake of using plain HTML instead of Phoenix’ Form helpers was too weird. At least I found out which part of the Router I needed to comment out for my code to work without the token. My coworker explained it to me later.
  3. Random problem: I added .elixir_ls/ to my .gitignore but it doesn’t do anything. Every time I want to commit something, I have about 20 changed files under .elixir_ls/. I actually copied this from one of our team’s project but it doesn’t work. My coworker couldn’t help either.

But it’s a start. For this week, I am going to provide some kind of view for what’s persisted (just a list or something so you can see that something happened in the user interface) and try to add some validations by writing tests first. So far, everything breaks when something other than a comma-separated list of integers is sent from the input field which isn’t really useful.

Another thing we did today: Have our first office-wide meditation session. Only 3 people from my department showed up, but 2 others (from other departments) already told me they forgot about it and would love to join next time. Yay!