All pastes #105865 Raw Edit

Miscellany

public ruby v1 · immutable
#105865 ·published 2006-07-29 23:14 UTC
rendered paste body
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  enddef 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