bcrypt 是哈希不是加密,没有解密一说。
快来快来,项目太多,人不够了。
<script></script>
内嵌在页面。/assets/javascript
下新建任意一个 coffee 文件,默认都会被打包到 application.js
中。顶楼的路径是符合惯例的。没对外开放,说明需要小白鼠啊😃
建议不要在 Rails 上叠加 grape,不然处理各种兼容问题烦得要死。要不用 Rails 要不用 Grape。
greap 是啥?
https://m.ucloud.cn/mobile/product/udocker.html
我在学 kubernates,既然 ucloud 自己有一套可以先试试。
可以用 UDocker,如果还用脚本管理不够容器 style。
把 password 写到 URL 里
🤦♂️
那么最近在折腾什么呢?
赞成
不打算使用。
如果我维护这段代码第一反应会是我艹。这就是一段没有文档的 DSL,只有写的人觉得爽,后人没法维护。
Rspec 难写难读,读的时候要把每层 context 的 before 和 let 都看一遍,才知道 case 的上下文是什么。
Minitest 是 plain Ruby,Ruby 的代码规范、重构方法、抽象逻辑都适用,懂得写好 Ruby 的也就懂得写好 Minitest。这也就是为什么 Rspec 的文章比 Minitest 多那么多,其实是 Rspec 里面乱七八糟的东西太多了。
Minitest 不推崇不必要的抽象。
It depends... https://tools.ietf.org/html/rfc7234
Rspec 可以让测试代码快速膨胀。
可以,没什么问题。
并不会,我贴下完整代码:
# File activemodel/lib/active_model/secure_password.rb, line 53
def has_secure_password(options = {})
# Load bcrypt gem only when has_secure_password is used.
# This is to avoid ActiveModel (and by extension the entire framework)
# being dependent on a binary library.
begin
require "bcrypt"
rescue LoadError
$stderr.puts "You don't have bcrypt installed in your application. Please add it to your Gemfile and run bundle install"
raise
end
include InstanceMethodsOnActivation
if options.fetch(:validations, true)
include ActiveModel::Validations
# This ensures the model has a password by checking whether the password_digest
# is present, so that this works with both new and existing records. However,
# when there is an error, the message is added to the password attribute instead
# so that the error message will make sense to the end-user.
validate do |record|
record.errors.add(:password, :blank) unless record.password_digest.present?
end
validates_length_of :password, maximum: ActiveModel::SecurePassword::MAX_PASSWORD_LENGTH_ALLOWED
validates_confirmation_of :password, allow_blank: true
end
end
这一行:
record.errors.add(:password, :blank) unless record.password_digest.present?
如果 password_digest 不存在,就会报 password 为空,这样创建用户的时候校验通不过。
源码:
validates_confirmation_of :password, allow_blank: true
如果 password 为空就不校验,所以你不要传 password 参数(去掉表单项)就行。
你的问题可以简化为:
class A
def a_method
"call from a"
end
end
class B
def b_method
a_method
end
end
B 定义在 A 里面和外面对于实例方法并没有什么不同——实例方法需要通过实例调用。
想要用 B 调用 A 的方法,那么 new 一个实例:
class B
def b_method
A.new.a_method
end
end
奥,你定义了自己的 Ruby 语法。这个语法在 MRI 里不能执行,也许自己写一个解释器可以。
你提问都说了“跨作用域”,跨作用域当然是不能访问拉。
X-Y Problem http://coolshell.cn/articles/10804.html
楼主已匿
这里不容忍人身攻击,早几十楼就应该封了。
大文件直传云储存。