0

我在我的 Rails 应用程序中集成了一个 html 模板。它实际上是一个单页模板,但使用锚点将不同的部分呈现为页面。喜欢,

localhost:3000/#home
localhost:3000/#email

以过渡到不同页面的效果呈现这些锚点。现在,我的控制器中有这个,

 if @message.valid?
      NotificationsMailer.new_message(@message).deliver
      redirect_to(root_path, :notice => "Message was successfully sent.")
 else
      flash.now.alert = "Please fill all fields."
      redirect_to root_path(anchor: 'email')
 end

在 else 部分中,重定向后浏览器中的 url 确实更改为,localhost:3000/#email但仍显示localhost:3000/#home锚点部分。实际单击localhost:3000/#email导航栏中的链接后,更改主页并呈现email锚点。

DevTools 和 Firebug 并没有在控制台中显示任何错误。有什么问题?

任何帮助将不胜感激。

4

0 回答 0