页面刷新后显示视图中的实例值(生产)
我正在使用 Rails 2.3.4 & ruby 1.8.7
我正在尝试在我的应用程序中打印实例变量。
实例变量在 deal_portal/base_controller.rb
中的方法中初始化,而视图则通过 deal_portal/mobile_controller
中的方法呈现。当我查看页面时,实例变量的值不存在,但是一旦刷新页面,就会显示该值。
延迟的原因可能是什么,因为这种情况仅在生产中发生
编辑:
deal_portal/base_controller.rb
def validate_trans
@voucher_urls = payment_info["voucher_urls"]
end
deal_portal/mobile_controller.rb
class DealPortal::MobileController < DealPortal::BaseController
def payment_success
render :template => "deal_portal/mobile/payment_success.html.erb"
end
end
deal_portal/mobile_native_app_controller.rb
class DealPortal::MobileNativeAppController < DealPortal::BaseController
before_filter :validate_trans, :only => [:payment_success]
end
现在在购买后的视图文件 payment_success.html.erb 中完成后,
@voucher_urls
不会显示,刷新页面后,它就会变得可见。
I'm using rails 2.3.4 & ruby 1.8.7
I'm trying to print a instance variable in my application.
The instance variable is getting initialized in a method in deal_portal/base_controller.rb
, while the view is rendered from a method in deal_portal/mobile_controller
. When I view the page, the value of instance variable is not present, but once the page is refreshed the value is displayed.
What could be the cause of delay as this happens only in production
EDIT:
deal_portal/base_controller.rb
def validate_trans
@voucher_urls = payment_info["voucher_urls"]
end
deal_portal/mobile_controller.rb
class DealPortal::MobileController < DealPortal::BaseController
def payment_success
render :template => "deal_portal/mobile/payment_success.html.erb"
end
end
deal_portal/mobile_native_app_controller.rb
class DealPortal::MobileNativeAppController < DealPortal::BaseController
before_filter :validate_trans, :only => [:payment_success]
end
Now in the view file payment_success.html.erb
after the puchase is made, the @voucher_urls
is not displayed and after refreshing the page, it becomes visible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论