我的应用程序中有拍卖和出价对象,当有人按下BID BUTTON然后调用创建出价的BID CREATE控制器,然后在拍卖对象上做一些其他事情:
BIDS控制器 - >创建
@auction.endtime += @auction.auctiontimer
@auction.winner = @auction.arewinning
@auction.save
Run Code Online (Sandbox Code Playgroud)
拍卖模型
before_update :set_endtime
def set_endtime
self.endtime=self.starttime+self.auctiontimer
end
Run Code Online (Sandbox Code Playgroud)
所以问题是:在这个特定的@ auction.save中,C如何才能跳过"回调前"
在我的Rails应用程序上安装Bcrypt之后,存在验证问题:password =>"不能为空",即使填写了表单:
这是我的用户模型
class User < ActiveRecord::Base
before_save { self.email = email.downcase }
validates :username, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true,
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
has_secure_password
validates :password, length: { minimum: 6 }
end
Run Code Online (Sandbox Code Playgroud)
我已尝试过rails c,现在出现了摘要:
User.create:
User.create(username: "Riprova", email:"testato@gmail.com", password: "nonfunzia", password_confirmation:"nonfunzia")
<User id: 15, username: "Riprova", name: nil, surname: nil, email: "testato@gmail.com", gender: nil, birth: nil, created_at: "2013-08-11 15:35:03", updated_at: "2013-08-11 15:35:03", password_digest: "$2a$10$Q/5qtZYDXRcFsUWgve3JL.wui4hSHLhGgsuO0C6TTkBY..."> …Run Code Online (Sandbox Code Playgroud)