Sha256: edf4d6656b0977859477cd64a6439994d77a1bffcd1151fc3735baf489b8d84f
Contents?: true
Size: 1.31 KB
Versions: 10
Compression:
Stored size: 1.31 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 = { 'desired_slug' => 'row_map[:slug]', '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
10 entries across 10 versions & 1 rubygems