Alisha Taylor

Joined

150 Experience
1 Lesson Completed
0 Questions Solved

Activity

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'
end

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

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

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

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

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.