Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

Is it bad to do return render? I am doing this to NOT also allow a redirect.

def create
    @patient = Patient.new(params[:patient])
    if  [email protected]
      @patient.user.password = ''
      @patient.user.password_confirmation = ''
      return render is_admin? ? 'new_admin' : 'new'
    else
      #Fire off an e-mail
      PatientMailer.welcome_email(@patient).deliver
    end

    if current_user == @patient
      sign_in @patient
    else
      redirect_to patients_path
    end
  end
share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Writing it like this makes it look the render returns a meaningful value that is then returned by create and used by the code that calls create, which is not the case. So instead I would write:

render is_admin? ? 'new_admin' : 'new'
return

This makes it clear that render is solely used for its side effects and create does not return a value (other than nil).

share|improve this answer
    
Thank you!!!!!! –  Chris Muench Feb 25 '11 at 19:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.