Sha256: 75e1d075a1ca3e204e4a8c79fdb39fdaeabb2242c28da8a5f4c1bdb8b3ad4311
Contents?: true
Size: 1.27 KB
Versions: 6
Compression:
Stored size: 1.27 KB
Contents
class FaqImport < ScaffoldLogic::DataImport # Class Methods ================================================================================== def self.test( path='public/sample-faqs.xls' ) self.run path end # Instance Methods =============================================================================== def process_row if faq = Publication.first.managed_contents.where(:slug => row_map[:slug].downcase).first || Publication.first.managed_contents.new(:slug => row_map[:slug].downcase) COLUMNS_BY_MODEL_FIELDS.keys.each do |_field| _content = eval(COLUMNS_BY_MODEL_FIELDS[_field]) faq.send("#{_field}=", _content) unless _content.blank? end faq.headline ||= faq.subheader faq.save @errors = faq.errors end @errors end protected COLUMNS_BY_MODEL_FIELDS = { 'headline' => 'row_map[:title]', # this is used as the title of the page and the link text of links pointing to the page 'summary' => 'row_map[:summary]', # used as meta description 'keywords' => 'row_map[:keywords]', 'headline_short' => 'row_map[:subheader]', #in my spreadsheet this was the shortened version of the question so it'd fit nicely. 'breadcrumbs' => 'row_map[:breadcrumbs]', 'content' => 'row_map[:content]' } end
Version data entries
6 entries across 6 versions & 1 rubygems