I would like to DRY this following code. I know I can combine the if and else statements into one line but is there a better approach? Thank you,
def group_access
@group = Group.find_by_url(params[:id])
if user_signed_in?
if @group.is_private == true and current_user.id == @group.user_id
return
end
if @group.is_private == true and current_user.id != @group.user_id
render "show_noaccess"
end
end
if !user_signed_in?
if @group.is_private == false
return
end
if @group.is_private == true
render "show_noaccess"
end
end
end
1 Answer