我正在尝试通过传递参数来呈现显示操作,但是当没有用户登录时,不会呈现显示页面。这是我的控制器:
class QrCodesController < ApplicationController
def show
@user = User.find_by_qr(params[:id])
if @user.nil?
redirect_to root_path
end
end
end
这是我的观点:
This is the qr-code page of <%= @user.fname %> <%= @user.lname%>
但是,当任何用户登录时,显示页面都会完美呈现。
rails 服务器还显示了完美渲染的显示动作:
Started GET "/qr_codes/9M9JZLiemrNdS_g90mZ14w" for 127.0.0.1 at 2013-08-02 18:29:55 +0545
Processing by QrCodesController#show as HTML
Parameters: {"id"=>"9M9JZLiemrNdS_g90mZ14w"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."qr" = '9M9JZLiemrNdS_g90mZ14w' LIMIT 1
Rendered qr_codes/show.html.erb within layouts/application (0.7ms)
Rendered layouts/_shim.html.erb (0.0ms)
Web Load (0.3ms) SELECT "webs".* FROM "webs" WHERE "webs"."id" = 2 LIMIT 1
Rendered layouts/_header.html.erb (3.2ms)
Rendered layouts/_footer.html.erb (0.0ms)
Completed 200 OK in 54ms (Views: 52.4ms | ActiveRecord: 0.5ms)
我正在使用 rails 3.2.13、ruby 1.9.3p429 和 devise 3.0.0。用户模型不是由设计生成的。
请帮忙。
编辑: 这是触发显示操作的链接:
http://localhost:3000/qr_codes/9M9JZLiemrNdS_g90mZ14w