Topic: Deep If Clauses
Hi, I find that I am writing a lot of deep IF clauses (on average 4 nested IFs) in my controllers, and that I have long chains of IF clauses in my views. For example, some view code might look like this:
<% If logged_in? and own_blog? and comments_exist? etc... %>
<%= display some stuff %>
<% end %>
Occasionally I put the IF chains in a private method to clean things up (or more accurately put the dirty stuff out of view). Is there a better strategy to deal with long chains of requirements in controllers and views?