Guest User

Untitled

a guest
Aug 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. ## lib/paperclip_processors/laod_file.rb
  2. module Paperclip
  3. class LoadFile < Processor
  4.  
  5. def make
  6. File.readlines(@file.path).collect(&:chomp).each do |line|
  7. email, account_number, sub_number, eid, premium_code, keycode, order_date, description = line.split("\t")
  8.  
  9. MailingList.new(email => :email, account_number => :account_number, sub_number => :sub_number, eid => :eid,
  10. premium_code => :premium_code, keycode => :keycode, order_date => :order_date, description => :description)
  11. end
  12. end
  13. end
  14. end
  15.  
  16. ## app/models/mailing_list.rb
  17. class MailingList < ActiveRecord::Base
  18.  
  19. has_attached_file :list_file,
  20. :processors => [:load_file]
  21.  
  22. end
Add Comment
Please, Sign In to add comment