Trail Valet for the World on Rails

Zachary Williams
2 min readMay 5, 2021

--

Around dusk in Atlanta a group of mountain bikers meet at popular breakfast spot and prepare for the nights adventure. The group then rides down the street and dips through one of Atlanta’s nearby parks. Riding down a hill the riders are shot through the park past a group of people playing tennis. The ride leader then disappears into some bushes and the riders follow. Suddenly the riders are in a well maintained trail system hidden from the day time and the city. The trails are maintained by “Trail Valet” a mysterious figure who takes care of maintaining the trails and building new features. My idea is to bring this figure to the masses using the powerful framework, Ruby on Rails and you!

Trails Valet is an app for people to post issues on a trail that may need to be fixed and/or build new features to increase the fun factor. Users can then show the task as completed, improving the trail systems for all.

To begin this project I used Rails generators to build routes, models, associations, controllers, and migrations. Generators create code that is repeated in many times in different locations and save developers lots of time. This repeated code is called boilerplate code. The first generator I used was the resource generator. This created my model, database table, controller, a views folder, routes, and relationships. I was able to use this generator effectively by mapping out my project before hand to understand how my models would interact with each other and what attributes they would have. Later in the project I needed to change my database and I was able to write migrations from the command line using generators. All I needed to include was the table, column name, and datatype. Using generators I was able to work much more efficiently and focus more on concepts.

Another aspect of rails I found useful was form_for and partials. Multiple places in my code had new and edit forms. These forms are very similar and redundant . Using form_for and partials I was able to DRY(Don’t Repeat Yourself) up my code and make my code more abstract. Form_for uses a model to build a form and saves you time writing HTML. If the model is unsaved without attributes the form will be blank and fit for the new model. If the model has attributes form_for can fill in the blanks making it perfect for an edit form. Using partials I was able to move the code to its own file and render the file in the view of two different pages.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response