ruby seed_fu_gen.rake
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby seed_fu_gen.rake相关的知识,希望对你有一定的参考价值。
namespace :seed_fu_gen do
desc 'generate seed-fu file for line.'
task dump: :environment do |_t|
j = ActiveSupport::JSON
%w(
Affiliation
AimCategory
AimScale
Aim
AroundAppraiser
AshitaUser
AssessmentPeriod
Assessment
Axis
AxisTemplate
Company
CompanyNotice
Division
Employment
EvaluationItemScaleTemplate
EvaluationItemScale
EvaluationItemTemplate
EvaluationItem
EvaluationPeriod
EvaluationSheetAroundAppraiser
EvaluationSheetReadable
EvaluationSheetStatusLog
EvaluationSheetTemplate
EvaluationSheetViewableUser
EvaluationSheet
GradeTable
Grade
LevelTable
Level
MailTarget
MailTemplate
MarkNotationTable
MarkNotation
PerquisiteBenefit
Perquisite
Rate
Rating
UserHistory
UserLabelChoice
UserLabelValue
UserLabel
UserMail
User
ViewableUser
).each do |class_name|
puts class_name
SeedFu::Writer.write("./db/dump/#{class_name.underscore}.rb", class_name: class_name) do |w|
klass = class_name.constantize
options = if klass.column_names.include?("type")
{ methods: :type }
else
{}
end
klass.all.each do |x|
# w << x.as_json(options.merge(except: [:created_at, :updated_at]))
# w << x.attributes
w << j.decode(j.encode(x, options))
end
end
end
end
end
以上是关于ruby seed_fu_gen.rake的主要内容,如果未能解决你的问题,请参考以下文章
Ruby运算符
Ruby 25 岁了!Ruby 之父说 Ruby 3 有望 3 倍提速
如何学习ruby?Ruby学习技巧分享
ruby Ruby脚本,看看是否用openssl编译了ruby
什么是ruby?
ruby和ruby ee