On Miércoles, 10 de Febrero de 2010 01:15:58 joelkeepup escribió:
> ok cool good suggestions, I found couple more problems mainly on
> editing in the parent view, first one is if you add an attachment from
> within the email form it doesnt work. Any ideas of what could be
> wrong?  How can I debug?
>
> I click edit on the email view, add an email_attachment, then I dont
> see the params being passed when I click update:
>
> Processing EmailsController#update (for 127.0.0.1 at 2010-02-09
> 19:13:51) [PUT]
>   Parameters: {"commit"=>"Update", "authenticity_token"=>"r+EVpxz0tg/
> wFfeVVgmMlq3u0vp5G8x7hCpzFUWgD/A=", "id"=>"1", "associated_id"=>"",
> "record"=>{"status"=>"", "name"=>"fred", "cc"=>"", "bcc"=>"",
> "from"=>"barney", "to"=>"myemail", "subject"=>"test",
> "application_step"=>{"title"=>"", "application"=>{"id"=>"1"},
> "id"=>"2", "description"=>"", "complete"=>"true"}}}

Have you set config.update.multipart? What it's the file field's name? I think 
you aren't gettting file field in the parameters, you can inspect the html code 
with firebug and check form is generated correctly. If you can't find the 
problem post your controller, helper overrides and models if you have 
associations.

>
>
> thanks
> Joel
>
>
> On Feb 5, 3:31 am, "Sergio Cambra .:: entreCables S.L. ::."
>
> <[email protected]> wrote:
> > 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]

-- 
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.

Reply via email to