0
<% if user_signed_in? %>
    <!-- lots of html/erb -->
<% end %>

This view pattern seems to not separate concerns.

I wrap several views in my app with logic demanding the user is signed in and would instead like to separate concerns and put the <% if user_signed_in? %> logic where it belongs...this seems like a decorator thing to me (hence the Draper tag).

What is best practice here?

brntsllvn
  • 931
  • 11
  • 18

1 Answers1

0

Not sure understood your question, but try to answer. At first to separate logic you dont need to use decorators in front of all, they serves for a little another thing. To separate logic you can use simple partials depending on current user state, for ex:

<% if user_signed_in? %>
    <%= render 'file_with_html_for_signed_user' %>
<% else %>
    <%= render 'file_with_html_for_non_signed_user' %>
<% end %>

You can declare this statement in your layouts/application.html.erb

Avdept
  • 2,261
  • 2
  • 26
  • 48