更新时间:2023-12-01 19:44:10
尝试重定向到 root_path
而不是'/ static_pages / home'
尽管如此,您可能会遇到另一个问题: @user .save
将尝试保存新用户,而不是更新现有的用户。
You'll probably have a different problem though: @user.save
will try to save a new user instead of updating the existing one.
还要考虑隐式呈现视图,而不是显式地重定向回相同的路径。这样,整个if / else块可以减少到: flash [:notice] =开发者被指责!!除非@ user.save
Also consider implicitly rendering the view instead of explicitly redirecting back to the same path. That way, the entire if/else block can be reduced to: flash[:notice] = "Developers to be blamed !!" unless @user.save
另请注意:单页应用程序大多在客户端上呈现。控制器仍应根据REST原则进行设计。
Further note: Single page applications are mostly rendered on the client. The controllers should still be designed according to REST principles.