Ok, thanks for the help, I seem to have it working now, not sure if
this is the best way, but for others struggling: (if someone has a
better way, please let me know)
class EmailAttachmentsController < ApplicationController
active_scaffold :email_attachment do |config|
config.columns.add :body
config.create.multipart = true
config.update.multipart = true
config.create.columns = [:body]
config.update.columns = [:body]
config.list.columns = [:name,:body,:content_type]
config.create.link.page = true
config.update.link.page = true
end
def before_create_save(record)
record.uploaded_file = params[:record][:body]
end
def before_update_save(record)
record.uploaded_file = params[:record][:body]
end
def download_file
@image_data = EmailAttachment.find(params[:id])
@image = @image_data.body
send_data(@image, :type => @image_data.content_type, :filename
=> @image_data.name, :disposition => 'inline')
end
end
Then on Model:
class EmailAttachment < ActiveRecord::Base
belongs_to :email
def uploaded_file=(incoming_file)
self.name = incoming_file.original_filename
self.content_type = incoming_file.content_type
self.body = incoming_file.read
end
end
--
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/activescaffold?hl=en.