Skip to content
baban edited this page Mar 31, 2015 · 8 revisions

Document is now translating please wait....

About Factoryfilter

When you want to translate and load data (or translate and dump data), factory filter is to solve this problem.

FactoryLoadFilter

factory filter is ruby DSL (defined "config/flextures.factory.rb"). below sample, is translate and load users table data. users table's "last_login_date" column data set 3 day before time.

Flextures::Factory.define :users do |f| 
  f.last_login_date = 3.days.ago
end

if you cannot load table data. At first, you should test Model binding argument set! Factory load filter second argument is used to bind ActiveRecord Model. Almost problem is solved this method.

Flextures::Factory.define :users, User do |f| 
  f.last_login_date = 3.days.ago
end

filter block can receive second, third argument

Flextures::Factory.define :users do |f,filename,extention| 
  f.last_login_date = 3.days.ago
end
argument description
1 table name
2 file name
3 file extention(:csv or :yml)

FactoryDumpFilter

Factory dump filter translate dump data.

Dump filter is written in "config/flextures.factory.rb"

below sample is password string to translate base64 encode.

Flextures::DumpFilter.define :users, {
  :encrypted_password => lambda { |v| Base64.encode64(v) }
}

if you data dump is missed, almost problem is solved to translate Base64 ecode data.