Putting presentation logic in controller is a good practice in Ruby?

Viewed 685

Some recommendation [1] suggest you to use

<%= current_user.welcome_message %>

instead of

<% if current_user.admin? %>
  <%= current_user.admin_welcome_message %>
<% else %>
  <%= current_user.user_welcome_message %>
<% end %>

But the problem is you must have the decision logic somewhere in your code.

My understanding is putting the decision in template is better than controller as it make your controller more clean. Is it correct?

Are there better way to handle this?

http://robots.thoughtbot.com/post/27572137956/tell-dont-ask

10 Answers
Related