簡體   English   中英

用戶通過設計看到其他用戶的內容

[英]Users seeing other users content w/ Devise

我在Rails上構建了一些簡單的東西,並且安裝了Devise。 用戶登錄並創建鏈接 -我已經創建了一個帳戶,創建了一些鏈接,然后當我創建另一個帳戶時,我可以轉到/ links / 5並仍然看到其他用戶已發布的內容。

我正在尋求使該應用程序盡可能個人化,有關如何解決此問題的任何想法?

一種選擇是在LinksController中使用一個簡單的before_filter。 就像是:

def check_authorization
  if current_user != link.user
    redirect_to ... (Redirect as appropriate for your app)
  end
end

假設有一個鏈接方法將獲取當前鏈接。 就像是

def link
  @link ||= Link.find(params[:id])
end

正如前面的評論者所提到的,Cancan也是一個可行的選擇。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM