Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## lib/paperclip_processors/laod_file.rb
- module Paperclip
- class LoadFile < Processor
- def make
- File.readlines(@file.path).collect(&:chomp).each do |line|
- email, account_number, sub_number, eid, premium_code, keycode, order_date, description = line.split("\t")
- MailingList.new(email => :email, account_number => :account_number, sub_number => :sub_number, eid => :eid,
- premium_code => :premium_code, keycode => :keycode, order_date => :order_date, description => :description)
- end
- end
- end
- end
- ## app/models/mailing_list.rb
- class MailingList < ActiveRecord::Base
- has_attached_file :list_file,
- :processors => [:load_file]
- end
Add Comment
Please, Sign In to add comment