Sha256: e4880647095f8690ba160977723da489d1b04e5569d9f97b41bb4283aa604a1e

Contents?: true

Size: 910 Bytes

Versions: 85

Compression:

Stored size: 910 Bytes

Contents

class OldPageAttachment < ActiveRecord::Base
    def create_paperclipped_record
      options = {
        :asset_file_size => size,
        :asset_file_name => filename,
        :asset_content_type => content_type,
        :created_by_id => created_by
      }
      
      # In newer versions of page_attachments we have title and description fields.
      options[:title] = title if respond_to?(:title)
      options[:caption] = description if respond_to?(:description)
      
      a = Asset.new(options)
      a.save
      
      # Re-attach the asset to it's page
      page = Page.find(page_id)
      p = PageAttachment.create(:asset_id => a.id, :page_id => page.id)
      
      # Circumvent acts_as_list before_create filter to set the original page_attachment position.
      PageAttachment.update_all("position=#{position}", "id=#{p.id}") if respond_to?(:position)
      
      a
    end          
end

Version data entries

85 entries across 85 versions & 6 rubygems

Version Path
trusty-clipped-extension-2.0.4 app/models/old_page_attachment.rb
trusty-clipped-extension-2.0.3.pre.beta app/models/old_page_attachment.rb
trusty-clipped-extension-2.0.2.pre.beta app/models/old_page_attachment.rb
trusty-clipped-extension-2.0.1.pre.beta app/models/old_page_attachment.rb
trusty-clipped-extension-2.0.0.pre.beta app/models/old_page_attachment.rb
trusty-clipped-extension-1.1.1 app/models/old_page_attachment.rb
trusty-clipped-extension-1.1.0 app/models/old_page_attachment.rb
radiant-clipped-extension-1.1.2 app/models/old_page_attachment.rb
trusty-clipped-extension-1.0.11 app/models/old_page_attachment.rb
trusty-clipped-extension-1.0.10 app/models/old_page_attachment.rb
trusty-clipped-extension-1.0.9 app/models/old_page_attachment.rb
trusty-clipped-extension-1.0.8 app/models/old_page_attachment.rb
trusty-clipped-extension-1.0.7 app/models/old_page_attachment.rb
trusty-clipped-extension-1.0.6 app/models/old_page_attachment.rb
trusty-clipped-extension-1.0.5 app/models/old_page_attachment.rb
trusty-clipped-extension-1.0.4 app/models/old_page_attachment.rb
trusty-clipped-extension-1.0.3 app/models/old_page_attachment.rb
trusty-clipped-extension-1.0.2 app/models/old_page_attachment.rb
trusty-clipped-extension-1.0.1 app/models/old_page_attachment.rb
trusty-clipped-extension-1.0.0 app/models/old_page_attachment.rb