Alisha Taylor


760 Experience
7 Lessons Completed
0 Questions Solved


Posted in Pair Programming on Rails Scopes Discussion

I know this is old, but going to answer anyway for future users. You have not defined "Event" here so it doesn't know what to do with that. Try something like:

irb(main):007:1* class Event
irb(main):008:0> end
=> nil
irb(main):009:0> event =
=> #<Event:0x000000011b86db18>

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'

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

© 2023 GoRails, LLC. All rights reserved.