2
我試圖強制用戶在我的文章控制器中調用此更新動作時登錄(我正在嘗試逐步參與),但是一旦他們登錄,我想仍然稱這個動作而不是停止。如何強制用戶在某個動作上登錄並稍後執行
def update
@article.attributes = params[:article]
@article.save
#store this article as a session variable
session[:pending_article] = @article.body
respond_with(@article, :location => article_url(@article))
end
現在我使用的是需要用戶的動作登錄
def require_user
unless current_user
store_location
flash[:notice] = "You must be logged in to access this page"
redirect_to login_url
return false
end
end
然而一個的before_filter,據我所知,過濾器停止原來的動作,一旦他們重新定向之前,因此更新不會被調用。基本上,我想要一個用戶登錄來保存文章,但我想保存他們的工作,所以我將文章主體存儲在稍後抓取的會話變量中。有沒有更好的方法來要求用戶登錄進行操作,但是之後會調用它?
將會話變量保存在require_user方法中就是票證。謝謝! – Hirthy 2011-04-25 00:17:05