小编Sci*_*ode的帖子

我的rails 4应用程序上的每个link_to都被调用两次

我正在使用我的Rails 4应用程序遇到一些不寻常的行为.每次我点击视图中的link_to,我的控制器动作都会被调用两次.例如:

在我的root_url标准呼吁users_profile:

<%= link_to('User Profile', users_profile_path, :class => "logout-button") %>
Run Code Online (Sandbox Code Playgroud)

当我单击此链接时,我的控制台显示以下输出:

Started GET "/users/profile" for 127.0.0.1 at 2013-11-25 20:45:53 -0200
Processing by Users::SessionsController#profile as HTML
  User Load (0.7ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 45 ORDER BY "users"."id" ASC LIMIT 1
  InvestorProfile Load (0.5ms)  SELECT "investor_profiles".* FROM "investor_profiles" WHERE "investor_profiles"."user_id" = $1 ORDER BY "investor_profiles"."id" ASC LIMIT 1  [["user_id", 45]]
  EmployeeProfile Load (0.5ms)  SELECT "employee_profiles".* FROM "employee_profiles" WHERE "employee_profiles"."user_id" = $1 ORDER BY "employee_profiles"."id" …
Run Code Online (Sandbox Code Playgroud)

ruby routes ruby-on-rails link-to

6
推荐指数
2
解决办法
4496
查看次数

标签 统计

link-to ×1

routes ×1

ruby ×1

ruby-on-rails ×1