class FileAttachmentsController < ApplicationController before_filter :authorize before_filter :prepare def receive @new_attachment = FileAttachment.new(:task_id => @task_id, :parent_id => @task_id) @new_attachment.attributes = params[:new_attachment] @new_attachment.save # Set the flash and direct back to update action for task. flash[:notice] = 'File uploaded successfully' redirect_to_person_task end def remove FileAttachment.destroy params[:attachments_to_remove] flash[:notice] = 'Attachments removed' redirect_to_person_task end private def redirect_to_person_task redirect_to :controller => 'tasks', :action => 'edit', :id => @task_id, :person_id => @person_id end private def prepare task = Task.find(params[:task_id]) @task_id = task.id @person_id = task.person_id end end