【问题标题】:how to get paginate to work with public/index.html? (ruby on rails 3)如何让分页与 public/index.html 一起工作? (轨道上的红宝石 3​​)
【发布时间】:2013-05-04 04:41:03
【问题描述】:

我在 3 天前问过这个问题,但没有得到答复。 以下是其他信息的链接:how to get paginate to work instead of getting redirected to 'public/index.html'?

我将在这里澄清/简化问题。

我使用 public/index.html 作为我的访问者主页。用户登录后,新主页位于“/home”。在这个“/home”上,有一个提要。我在<%= will_paginate @posts %> 视图中使用它对提要进行分页。

您可能想象的问题是,当我尝试从分页单击第二页时,链接是http://www.mydomain.com/?page=2。这将重定向回 public/index.html。如何让分页功能正常工作?

提前致谢

【问题讨论】:

    标签: ruby-on-rails ruby will-paginate pagination


    【解决方案1】:

    为什么不删除public/index.html.erb?那是一个静态页面,你不能在上面有动态元素,比如分页。

    应用程序的根请求应该由根路由处理:

    root :to => "home#index"
    

    然后是app/views/home/index.html.erb中的分页逻辑。

    【讨论】:

    • public/index.html 适用于匿名访问者。我有 static_pages/home.html.erb 用于登录用户。我正在尝试让分页为home.html.erb 工作...如何删除public/index.html 并使其正常工作?
    猜你喜欢
    • 2022-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多