开发者

Wait for variable to be defined

I have this code in a Rails controller:

def show
  doc     = Document.find(params[:id])
  session = Crocodoc.get_session(doc.uuid)
  @url    = Crocodoc.session_based_viewer_url(开发者_如何学JAVAsession[:sessionId])
end

I need to wait until session is defined (or IOW wait for Crocodoc.get_session to return) before showing the view. How should this be handled?


It's already handled. The view is rendered right after the controller action returns (unless you render it explicitly during the action). At that point session will be out of scope, but @url will be defined.


I found that I had to rename the @url instance var to something else in order for it to get passed to the view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜