Alisha Taylor

Joined

760 Experience
7 Lessons Completed
0 Questions Solved

Activity

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.new
=> #<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'
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