Skip to content

Instantly share code, notes, and snippets.

@leofrozenyogurt
Created March 2, 2014 21:42
Show Gist options
  • Select an option

  • Save leofrozenyogurt/9314421 to your computer and use it in GitHub Desktop.

Select an option

Save leofrozenyogurt/9314421 to your computer and use it in GitHub Desktop.
refactor of user controller
if user_signed_in?
@user=current_user
@subscription= Subscription.new
@[email protected]
@all_talks=Talk.all
@[email protected]_watchings
@[email protected]_talks
#initiate totals for each state
@total_ny=0
@total_ny_ethics=0
@total_ca=0
@total_ca_ethics=0
@total_ca_bias=0
@total_ca_abuse=0
@certifications.each do |cert|
talk = cert.talk
# NY CREDIT
talk.state_codes.where(name: 'NY').where.not(credit_category: 'Ethics and Professionalism').each do |code|
product= code.credit
@total_ny += product
end
# NY ETHICS
talk.state_codes.where(name: 'NY', credit_category: 'Ethics and Professionalism').each do |code|
product= code.credit
@total_ny_ethics += product
end
# CA CREDIT
talk.state_codes.where(name: 'CA', credit_category:'General' ).each do |code|
product= code.credit
@total_ca += product
end
# CA ETHICS
talk.state_codes.where(name: 'CA', credit_category:'Legal Ethics' ).each do |code|
product= code.credit
@total_ca_ethics += product
end
# CA CREDIT
talk.state_codes.where(name: 'CA', credit_category:'Prevention / Detection / Treatment of Substance Abuse or Mental Illness' ).each do |code|
product= code.credit
@total_ca_abuse += product
end
# CA CREDIT
talk.state_codes.where(name: 'CA', credit_category:'Elimination of Bias in the Legal Profession' ).each do |code|
product= code.credit
@total_ca_bias += product
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment