Rails 4 - if @model.save cases -


how write if/unless statement, looks if and unless that?

respond_to |format|   if @request.save     if @request.product.require_approval      ## unless @request.project ##       stuff...     else       other stuff...     end   else         format.html { render action: 'new', notice: 'there error request.' }         format.json { render json: @request.errors, status: :unprocessable_entity }   end end    

thanks in advance.

unfortunately don't think can combined two. example think solution clear stick if:

if @request.product.require_approval && !@request.project

there articles can find online suggest avoiding chaining conditions unless, why think should stay if:


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -