title: Ruby on Rails: If you have 50 if-else statements in your after_create action, will that slow down your application?
body: <p>Is using 50 if-else statements too resource-intensive for one action?</p>
  
  <p>I'm doing something like this:</p>
  
  <pre><code>if team.players.count &gt; 1
     assign_team_type(..)
  elsif team.players.count &gt; 3
     assign_team_type(..)
  ...
  etc.
  ...
  end
  </code></pre>
  
  <p>Also, is it more efficient to place the 50 if-else statements in your create action inside your controller instead of the after_create method? Or would it be more efficient to use a case switch statement instead, or just avoid it altogether? </p>
  
  <p>EDIT: Thanks for the very quick responses! The code is for a community sports tournament to assign teams based on the number of players on that team. I'm trying to write something that assigns a team type to each team according to how many players are added to that team. So there are teams for 1 player, 3 players, 5 players, 7 players, etc., up to 200 players, which requires 50 if-else statements in total. </p>
  
  <p>The statements happen in the players_controller, after the user visits <a href="http://localhost/players/new" rel="nofollow noreferrer">http://localhost/players/new</a>, adds a player, and then the application decides what team to assign his or her team based on how many players are currently on that team. It's very straight-forward (a basic CRUD application that just needs these 50 if-else statements)</p>
  
  <pre><code>models:
  
  Team (has_many :players)
  Player (belongs_to :team)
  
  scaffold team name:string team_type:string
  scaffold player team_id:integer name:string
  </code></pre>
  
  <p>That's pretty much it :)</p>