Essentail Rails Design Pattern

Write Good Rails Code

LOGIC in View

場景

#TODO

Wrong

1
2
3
<% if current_user && current_user == post.user %>
  <%= link_to("Edit", edit_post_path(post))%>
<% end %>

Correct

1
2
3
<% if editable?(post) %>
  <%= link_to("Edit", edit_post_path(post))%>
<% end %>

Comments