Skip to content

Instantly share code, notes, and snippets.

@andrerpbts
Created March 15, 2012 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrerpbts/2044373 to your computer and use it in GitHub Desktop.
Save andrerpbts/2044373 to your computer and use it in GitHub Desktop.
refactory
# modo um
def index
@status = params[:status]
if @status == nil
@associados = Associado.all
else
@associados = Associado.find_all_by_status(@status)
end
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @associados }
end
end
# modo dois
def index
@associados = params[:status].blank? ? Associado.all : Associado.find_all_by_status(params[:status])
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @associados }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment