诸公 我发现看什么都没看文档提升功力提的快 还特么是内功 Ruby.Doc
还好注册的早
这个不错
#12 楼 @sundevilyang codeschool 里有很多 包括 TryGit & Git real 你可以去看看第一个是接着和 github.com 合作的 Git Real 的 PDF 在这里 你可以下回去看 Git Real
hi peter 我是按照 casts 上去做的 结果 nginx 总是现实默认画面
将这一部分注销后~现在又成 502 错误~看 Log 是说无法连接到upstream
[error] 15550#0: *1 connect() failed (111: Connection refused) while connecting to upstream,
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root html;
#}
现在是 404 页面了~ 修改了基础配置 重新安装了 Nginx 结果现在open() "/etc/nginx//html/50x.html" failed
怎么会指向到这里呢
2012/11/20 16:54:23 [error] 15044#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.103.68, server: localhost, request: "GET / HTTP/1.1", upstream: "http://192.168.103.212:5000/", host: "192.168.103.212:8081"
2012/11/20 16:54:23 [error] 15044#0: *1 open() "/etc/nginx//html/50x.html" failed (2: No such file or directory), client: 192.168.103.68, server: localhost, request: "GET / HTTP/1.1", upstream: "http://192.168.103.212:5000/", host: "192.168.103.212:8081"
2012/11/20 16:54:23 [error] 15044#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.103.68, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://192.168.103.212:5000/favicon.ico", host: "192.168.103.212:8081"
2012/11/20 16:54:23 [error] 15044#0: *1 open() "/etc/nginx//html/50x.html" failed (2: No such file or directory), client: 192.168.103.68, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://192.168.103.212:5000/favicon.ico", host: "192.168.103.212:8081"
#1 楼 @zzhattzzh 刚才把整个 controller 的过程走了一遍 发现 filter 工作是正常的 我把 Session 打开 用 cookies 就 OK 用 Session 的时候 就会报错 感觉像是无法给变量赋值
module SessionsHelper
def sign_in(user)
##cookies.permanent[:remember_token] = user.remember_token
session[:current_user_id] = user.id
session[:remember_token] = user.remember_token
current_user = user
end
def current_user=(user)
current_user = user
end
def current_user
##current_user ||= User.find_by_remember_token(cookies[:remember_token])
@current_user ||= User.find_by_id(session[:current_user_id])
end
def current_user?(user)
user == current_user
end
def signed_in?
!current_user.nil?
end
def sign_out
self.current_user = nil
cookies.delete(:remember_token)
session[:current_user_id] = nil
end
def signed_in_user
unless signed_in? #只有当no-sign的User才会被跳转
store_location
redirect_to signin_path, notice: "Please sign in."
end
end
def correct_user #对于已登陆User应该是直接转到首页就OK了
@user = User.find(params[:id])
redirect_to root_path unless current_user?(@user)
end
end
现在我 PUT 一个 User 的信息到别的 User 上的 update 这个 Action 上的时候 看过程貌似是当作 no-sign-in 的用户直接转到 sign-in 界面了。
def current_user
##current_user ||= User.find_by_remember_token(cookies[:remember_token])
@current_user ||= User.find_by_id(session[:current_user_id])
end
对比了几次感觉就是着两行的问题 用 cookies 没问题 Session。。。
解决了
多了一句 <%= javascript_include_tag "bootstrap-modal" %>
在app/views/layouts/application.html.erb
中
irb(main):008:0> user.valid?
User Exists (2.0ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER('[email protected]') LIMIT 1
=> false
irb(main):009:0> user.invalid?
User Exists (0.6ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER('[email protected]') LIMIT 1
=> true
正在学习Sample App
那个例子~搞定再来看这个