只显示主题贴
theone 写道wiisola 写道theone 写道update_all ["password =?", password], ['id=?,1]
那如何更新多个字段呢?第1个参数传hash好象不行。。
这样写
update_all ["username = ?, password =?", username, password], ['id=?',1]
谢谢,不过我找到办法了
validates_length_of :password, :in => 6..20, :allow_nil => true
原来allow_nil是这么个意思阿,以前误解了...
- 进入论坛 Ruby 版
不见得 写道update_attribute(s)
我本来就是用的这个
@user.update_attributes(:email => params[:user][:email], :im => params[:user][:im])
但是修改的时候会校验password,是通不过的,我就是想问有什么办法
- 进入论坛 Ruby 版
theone 写道update_all ["password =?", password], ['id=?,1]
那如何更新多个字段呢?第1个参数传hash好象不行。。
- 进入论坛 Ruby 版
我照Agile Web Development with Rails里第11章用户管理的做了,用了password这个虚拟字段。
user.rb中的部分代码:
validates_length_of :password, :in => 6..20
def password
@password
end
def password=(pwd)
@password = pwd
returen if pwd.blank
created_new_salt
self.hashed_password = User.encrypted_password(self.pa ...
- 进入论坛 Ruby 版
是指界面的还是程序里的?
是界面的话设置个jdk平台中文字体
是代码中的话有部分字体是不能正确显示汉字的
- 进入论坛 Ruby 版
- 浏览: 4748 次
- 性别:

- 来自: 南京

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
render与redirect_to的区 ...
redirect_to会执行被渲染的那个action,而render不会,这跟你 ...
-- by alanyuqiang -
#008_layouts和content_fo ...
这是最普遍的用法,不知道楼主有没研究过,content_for,yield在不同 ...
-- by alanyuqiang -
#008_layouts和content_fo ...
...
-- by alanyuqiang -
render与redirect_to的区 ...
不错,最近正为这个发愁呢!
-- by evil850209 -
如何在update一条记录的部 ...
theone 写道wiisola 写道theone 写道update_all [ ...
-- by wiisola






评论排行榜