关于 ruby?? on rails:使用 HAML 重定向 | 珊瑚贝

Redirecting with HAML


我想使用 HAML 重定向到我视图中的另一个页面,具体取决于变量的状态。

理想情况:

1
2
if days < 1
      redirect to /settings
  • 为什么要这么做?您应该在控制器中处理重定向。
  • 同意@AmitBadhekaPykihStaff,当您从控制器获取 days 变量时,您应该在控制器本身中处理这些事情
  • Okie dokie,菜鸟错误。通过您的反馈回答了我自己的问题。


不要通过你的视图处理重定向,使用你的控制器。

控制器:

1
2
3
if days > 1
    redirect_to edit_user_registration_path
end


来源:https://www.codenong.com/32990629/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_10047.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?