0
我想幹下面這段代碼。我知道我可以將if和else語句組合成一行,但有沒有更好的方法?謝謝你,導軌3:我該如何幹這個?
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
感謝您給我們! – user1461119