Cover image for Week 5— LiP notes: Ruby on Rails

Week 5— LiP notes: Ruby on Rails

dannylee8 profile image Danny Lee ・6 min read

[Image courtesy of @startupphotos twitter via Pexels.com]

What are LiP notes?

LiP notes or “Learning in Progress notes” is the best I could come up with to describe what I’m trying to collect in this article. I’m currently a full stack development student [Ali A’s story] at the Flatiron School’s NYC campus, located at 11 Broadway, adjacent to the Charging Bull by Arturo Di Modica, which stands in Bowling Green in the Financial District. You might wonder why the Flatiron School is named thusly, when its located in the Financial District. There is a background story, which Avi Flombaum touches upon in this great interview from The Start podcast.

But, I digress (which, may I say, is exceedingly common in my writing (and thinking). I started writing the LiP notes as a way to think and document my way through my learning process as a sort-of stream of consciousness. (You may also find I usurp the nuanced and exact definition of words and phrases to suit my particular generalized meanings.) For this, I apologize. If this is not your cup of tea, my hope for you, the reader, is that you manage to glean some useful information, whilst avoiding going down any unrelated rabbit holes. For those of you who enjoy the road not taken, spelunk away! But, be mindful if you are like me when it comes to time management, a time management system like the 🍅Pomodoro Technique 🍅 can be useful in limiting the time spent down the hole (I give 1 || 2 🍅 to an interesting idea before getting back to the task I was working on, and if it ⛰piques⛰ my interest I schedule a few more 🍅🍅🍅 later in the week.)

SO, back to my story, it had been a harrowing 4 weeks pushing through Ruby (without Rails), SQL, ORMs, ActiveRecord, Rack, Sinatra and now, have begun our introduction to Ruby on Rails. I’ve been slowly upgrading tools in my workflow, and figuring out errors that hinder my progress and that’s what this article is about: the problem or issue; the thought process to correct or alleviate; the solution I settled for; and finally, any afterthoughts or followup ideas. Comments, corrections, suggestions and interesting rabbit holes are always welcome! 👨🏻‍💻

Here’s a quick solution that I just tried out this morning, the Faker gem. It creates fake data for your database. I always need data for testing when working on labs, but can get stuck when I get too deep into thinking of names, movie titles, books that define me, etc. My lead instructor, Steven Doran @ Flatiron School used it in an example last week, and this week I finally had some time to read up on it and use it.

Available here, on Github. I checked the Readme.md and then went into a couple of the methods to see what they can provide. Pretty simple.

Here’s the simple tutorial I skimmed for commands to setup my Gemfile and get started. I deleted my Gemfile.lock and added this to the bottom of Gemfile:

gem ‘faker’

Added some code to my seeds.rb file in /db

**require** '*faker*'5.times **do
**  Student.create(
    first\_name:   Faker::Name.first\_name,
    last\_name:    Faker::Name.last\_name

Then I ran rails db:seed and checked my database browser and nothing happened. So, I hit ⬆ and ⏎, and nothing. So, I hit ⬆ and ⏎ again…nothing. Usually, repeating something 2 or 3 times makes it work finally, but this time, I had no luck. So, I clicked open database and found out I was in test.db, but there was also a development.db — opened that up, and 💥b00m💥, there’s 15 new 👨‍🎓students👩‍🎓.

Rabbit hole number 2 came up when trying to generate a new Rails site on top of an old one with:

rails new <appname>

I got the error:

Overwrite /home/dan/git/dreamercatcher/.gitignore? (enter "h" for help) \[Ynaqdhm\]

So, what does [Ynaqdhm] mean?

\] h
        Y \- yes, overwrite
        n \- no, do not overwrite
        a \- all, overwrite this and all others
        q \- quit, abort
        d \- diff, show the differences between the old and the new
        h \- help, show this help
        m \- merge, run merge tool

I hit ‘m’ for merge and got:

Please specify merge tool to \`THOR\_MERGE\` env.
Overwrite /home/dan/git/dreamercatcher/.gitignore? (enter "h" for help) \[Ynaqdhm\]

After some googling, I put this in my .zshrc:

export THOR\_MERGE=/usr/bin/code


source ~/.zshrc

And when I went through the cycle again and hit m, it went into merge mode.

Fun! 😅

My current list of VSC extensions:

I borrowed a macbook air from Flatiron, and am using iTerm2, with Oh My Zsh and Powerlevel10k prompt, Visual studio code for editing and my current alias list is:

# Aliases
# =====================
  # LS
  alias l='ls \-lah'
  alias ls='ls \-pGa'\# Git
  alias gcl="git clone"
  alias gst="git status"
  alias gl="git pull"
  alias gp="git push"
  alias gd="git diff | subl"
  alias gc="git commit \-v"
  alias gca="git commit \-v \-a"
  alias gb="git branch"
  alias gba="git branch \-a"
  alias gcam="git commit \-am"
  alias gbb="git branch \-b"\# Turcan Macros \- got the basis for **bam** and **cbam** from [Turcan Cicek](https://medium.com/@hcicek2811)
  alias bam='git clone "$(pbpaste)" && cd $(basename $\_ .git) && echo $(basename $\_ .git) > ~/.last\_clipboard\_entry && bundle install && code \-r .'
  alias cbam='cd .. && git clone "$(pbpaste)" && cd $(basename $\_ .git) && bundle install && code \-r .'
  alias pblast='cat ~/.last\_clipboard\_entry'
  alias cliplast=pblast
  alias capp='last\_dir=\`cat ~/.last\_clipboard\_entry\` && cat ../$last\_dir/app.rb && echo $last\_dir/app.rb'\# Learn aliases
  alias lff='learn \-\-f\-f'
  alias lsub='learn submit'\# edit .zshrc aliases
  alias vz='vi +$ ~/.zshrc; source ~/.zshrc'
  alias coz='code ~/.zshrc; source ~/.zshrc'
  alias cz='cat ~/.zshrc'
  alias sz='source ~/.zshrc'\# Rails aliases
  alias sg='rails s'
  alias tlog='tail \-n30 log/development.log'
  alias tlogs='tlog'
  alias cdav='cd app/views'

I also use a VMware Workstation 15 (v15.5) virtual machine, running a (beta) Fedora 31 Comp-Neuro ISO. The current stable version of Fedora is F30, Comp-Neuro is a beta for an upcoming release of the Neuro Fedora Spin (coming soon!) , which will be preloaded with FOSS Neuroscience software. Read more about the Neuro Fedora SIG and get involved here. Here’s the Windows 10-based computer it runs on. I’m especially proud of it because its the first one I built for myself 😁, its under the title i7–6700k. The rest on that page are computers built for my old boss, Cliff, at Badge Media. 🙏

Well, I feel like that’s all I have for this post. Stay turned for more random thoughts and rabbit holes! 🐰

Posted on Apr 23 by:

dannylee8 profile

Danny Lee


a nyc based programming enthusiast, who also loves handywork, propagating african violets, gardening, woodwork, welding, painting, and travelling to bali, to visit my future home.


markdown guide