Skip to content

Instantly share code, notes, and snippets.

@timruffles
Created November 30, 2010 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timruffles/722105 to your computer and use it in GitHub Desktop.
Save timruffles/722105 to your computer and use it in GitHub Desktop.
This view is way too smart... It'd be great to remove it all to helpers and plugins, but most important is BonusOffer.signup.enabled? && ! current_user.identity_verified?, buiz logic that is in the view :(
<%=
if not logged_in?
# Log in
# A button for each stake
@real_game.stake_amounts.sum do |stake_amount|
render 'games/buttons/login_to_play_stake', :stake_amount => stake_amount
end
elsif current_user.has_enough_funds_to_bet?
# A button for each stake
@real_game.stake_amounts.sum do |stake_amount|
if current_user.account_balance >= stake_amount
render 'games/buttons/play_stake', :stake_amount => stake_amount
else
render 'games/buttons/deposit_to_play_stake', :stake_amount => stake_amount
end
end
elsif BonusOffer.signup.enabled? && ! current_user.identity_verified?
# ID check
render 'games/buttons/signup'
else
# Deposit
render 'games/buttons/deposit_to_play'
end
%>
@timruffles
Copy link
Author

Line 23 is the worst part - this is a textbook example of buiz logic being encoded in the view

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment