Alisha Taylor


150 Experience
1 Lesson Completed
0 Questions Solved


Posted in How do I learn to write dry code?

I've been learning RoR for a year now and have a basic functioning site that people actually use, but my code is not even close to dry... it's probably wetter than the Amazon! Once you have the basics, where can you go to learn not just how to code, but how to code better? I'm open to any advice, suggestions, etc. I am trying to look for a mentor but just getting scammed...

Here is an example from my application controller for code that is used in multiple places on my site (would love suggestions on refactoring this):
def export_tips
@appointments = Appointment.order('service_id')
send_data @appointments.to_csv_tips, filename: 'tips.csv'

def export_ticketpayments
@appointments = Appointment.order('service_id')
send_data @appointments.to_csv_ticketpayments, filename: 'ticketspaymentitems.csv'

def export_batchmanifest
@batchmanifests = Batchmanifest.all
send_data @batchmanifests.to_csv_batchmanifest, filename: "batch_manifest-#{}.csv"

def export_pets
@clients = Client.all
send_data @clients.to_csv_pets, filename: 'pets.csv'

def export_clients
@clients = Client.all
send_data @clients.to_csv_clients, filename: 'clients.csv'

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2021 GoRails, LLC. All rights reserved.