dry - Rails Remove Duplication in Controller -


i learned rails , rails' dry principle.

i need making controller dry:

in 3 of controller actions have same if statement:

respond_to |format|     if @items.empty?       @cart.destroy       session[:cart_id] = nil     format.html { redirect_to products_path, notice: 'empty cart' }     else         if @line_item.save          format.html { redirect_to @line_item.cart, notice: 'item removed' }          format.js { @current_item = @line_item, @items }        end      end end   if @line_item.save   

i tried remove duplication using respond_with not work.

help me if.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -