You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<% if current_user && (current_user == @post.user ||
@post.editors.include?(current_user)) %>
<%= link_to 'Edit this post', edit_post_url(@post) %>
<% end %>
After:
<% if @post.editable_by?(current_user)) %>
<%= link_to 'Edit this post', edit_post_url(@post) %>
<% end %>
class Post < ActiveRecord::Base
def editable_by?(user)
user && (user == self.user || self.editors.include?(user))
end
end