DEV Community

loganwohlers
loganwohlers

Posted on

Automating the Boring Stuff in Rails (Rails Snippet Pack v1)

Before starting on the path to software development I worked in finance- which really meant I worked in Excel. A lot. Every day spent in spreadsheets sometimes exceeding 10,000 lines- every one of them belonging to an account with hundreds of thousands of dollars invested (at the minimum). Needless to say I had to get fast in excel- so I learned every keyboard shortcut and workflow process I could (it was my inability to actually write/automate the most inefficient processes that eventually drew me to coding) and it worked- I got really really fast. But since I've moved on to writing actual code in a text editor I'm slow. I was flying too close to the sun back in Excel- now I feel like molasses half the time I'm working on any new projects. Now to be fair- a bunch of this stuff is strictly muscle memory (I couldn't tell you the excel shortcuts I used- my fingers just knew)- but more than that it's also leveraging the tools available so that you can spend more time on the thinking and less time on the grunt work that is typing out an HTML form.

With all this in mind I've been making a conscious effort to speed up my code by utilizing hotkeys/shortcuts (s/o to my colleague Brian for his post on useful keyboard shortcuts- you can read that here- many of them work in conjunction w/ the rest of this post: https://dev.to/bouhm/you-should-be-using-keyboard-shortcuts-2poe) and I can already feel it making a big difference. Then I started working in Rails- typing the exact same form and controller syntax (since as a class we've been banned from using rails' scaffolding) and then Rails having the audacity to expect you to wrap everything '<%=' and '%>' (squids and ice cream codes- as they say in the industry) was driving me insane. Creating a simple RESTful route flow took way too long- so I eventually turned to snippets. I've seen and used them before (mainly in HTML) and they are objectively amazing- but I was having trouble finding ERB ones that would work well in rails- and even then I wanted stuff that was tailored for the kind of text I found myself typing over and over. The problem with snippets in my opinion though is that they are weird and the syntax is pretty unfriendly for a beginner:

Seriously what is this? I just want to add some squids and ice cream cones!

However it all clicked when I found- https://snippet-generator.app which immediately removed the barrier to entry and allowed me to start taking work I had done and turn it into snippets. Once I made a couple useful ones I couldn't stop- so I tried to compile a list of them that would not only be useful to myself- but to all of my classmates/fellow Flatiron students working through the second mod curriculum. For now it's not much- but it's certainly something that has sped up my flow tremendously and something that I will add to as I continue running into the same issues time and time again (plus with the generator they are VERY easy to write)- the next step from here will be to look into real automation of tasks- mainly via scripts. I want a push button start on my programs and working towards that continues to be a fun experience.

gif

link to github page w/ the snippets- more to come soon
https://github.com/loganwohlers/Rails-Snippets

Thanks for reading! Please leave any feedback and suggestions-

Logan

Top comments (2)

Collapse
 
sofiajonsson profile image
Sofia Jonsson

Thank you for doing this! Total game changer

Collapse
 
loganwohlers profile image
loganwohlers

No problem! It's amazing