def save return unless request.post? @contact = Contact.new(params[:contact]) @contact.user = current_user if @contact.save flash[:note] = "Contact successfully created" redirect_to(:controller => 'contacts', :action => 'list') else render :action => "create" end end def delete #need to do this twice, otherwise returns an object even though params[:id] is nil #contact = Contact.find_by_id_and_user_id(params[:id], current_user.id) contact = Contact.find_by_id_and_user_id(params[:id], current_user.id) unless contact flash[:note] = "Contact not found" redirect_to(:action => 'list') return end if contact.destroy flash[:note] = "Contact deleted" redirect_to(:action => 'list') else render :action => 'list' end end