Rails页面仅在刷新后应用

时间:2014-11-28 13:09:18

标签: ruby-on-rails ruby ruby-on-rails-4

所以,我几乎已经在Ruby on Rails中完成了一个练习应用程序。它有点像Q& A,但是更简单。我在导航栏上的站点名称上有一个link_to根路径。但问题是当我在另一个页面时,如果我点击主页名称,它不显示任何内容,只显示数据如果我按下刷新。

从日志中看,它在执行查询时停止运行,没有进一步..我已经部署了应用程序以供参考@ altur.herokuapp.com

请求期间的日志,

点击链接后

    Started GET "/" for 127.0.0.1 at 2014-11-28 18:36:07 +0530
Processing by QuestionsController#index as HTML
  Question Load (4.0ms)  SELECT "questions".* FROM "questions" ORDER BY created_at DESC
   (3.0ms)  SELECT COUNT(*) FROM "answers" WHERE "answers"."question_id" = $1  [["question_id", 1]]
  Rendered questions/index.html.erb within layouts/application (14.0ms)
  User Load (1.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Completed 200 OK in 78ms (Views: 69.0ms | ActiveRecord: 8.0ms)

按下刷新后,它会发出所有GET请求,页面显示为空白..

同样适用于“我的问题”链接..只是数据库查询而没有发出GET请求。

Processing by QuestionsController#userview as HTML
  Parameters: {"user"=>"1"}
  User Load (2.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
  User Load (2.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", "1"]]
  Question Load (3.0ms)  SELECT "questions".* FROM "questions" WHERE "questions"."user_id" = $1  [["user_id", 1]]
   (2.0ms)  SELECT COUNT(*) FROM "answers" WHERE "answers"."question_id" = $1  [["question_id", 1]]
  Rendered questions/userview.html.erb within layouts/application (11.0ms)
Completed 200 OK in 51ms (Views: 38.0ms | ActiveRecord: 9.0ms)

1 个答案:

答案 0 :(得分:0)

您似乎遇到了将类分配给元素的js库的问题。如果您在点击徽标链接后检查主页的html,您会注意到:

.class masonry

未分配给div

.blog-grid.

孩子也有同样的问题。你失去了所有的课程。我不确切知道您使用什么来创建此模板。但是在加载资产或执行ajax加载时检查错误,因为你似乎遇到了问题。