On Jueves, 4 de Febrero de 2010 21:08:43 joelkeepup escribió: > 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
You can use uploaded_file instead of body as column name and you can remove before_create_save and before_update_save > > 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 Or you can use body= instead of uploaded_file= -- Sergio Cambra .:: entreCables S.L. ::. Mariana Pineda 23, 50.018 Zaragoza T) 902 021 404 F) 976 52 98 07 E) [email protected] -- 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.
