hashid-rails:在Rails应用程序ActiveRecord模型中使用Hashids(http:hashids.orgruby)

时间:2021-02-01 03:01:00
【文件属性】:
文件名称:hashid-rails:在Rails应用程序ActiveRecord模型中使用Hashids(http:hashids.orgruby)
文件大小:19KB
文件格式:ZIP
更新时间:2021-02-01 03:01:00
ruby rails hashids RubyRuby Hashid Rails 该宝石可让您轻松在Rails应用程序中使用 。 您的模型将使用唯一的短哈希,例如“ yLA6m0oM”,“ 5bAyD0LO”和“ wz3MZ49l”,而不是使用诸如1、2、3之类的序号的模型。 数据库仍然会使用整数,因此可以随时添加或删除此gem。 重要信息:如果您需要从1.0之前的版本中维护相同的哈希值,请阅读。 安装 将此行添加到您的应用程序的Gemfile中: gem "hashid-rails" , "~> 1.0" 然后执行: $ bundle 基本用法 在要启用哈希值的ActiveRecord模型中包括Hashid Rails。 class Model < ActiveRecord :: Base include Hashid :: Rails end 继续使用Model#find输入hashid或常规的'ol id。 @person = Person . find ( params [ :hashid ] ) 获取模型的哈希值 您可以使用hashid方法访问任何模型的hashid 。 model = Model . fin
【文件预览】:
hashid-rails-master
----.gitignore(117B)
----hashid-rails.gemspec(2KB)
----.rspec(31B)
----gemfiles()
--------rails_5.2.gemfile(123B)
--------rails_4.2.gemfile(146B)
--------rails_5.1.gemfile(123B)
--------rails_6.0.gemfile(123B)
--------rails_5.0.gemfile(146B)
----bin()
--------setup(115B)
--------console(367B)
----.rubocop.yml(294B)
----CHANGELOG.md(3KB)
----LICENSE.txt(1KB)
----.github()
--------workflows()
----spec()
--------hashid()
--------support()
--------spec_helper.rb(389B)
----README.md(6KB)
----lib()
--------hashid()
----Appraisals(390B)
----Gemfile(128B)
----Rakefile(155B)

网友评论