Skip to content
  • Łukasz Strzałkowski's avatar
    edacdbfa
    Inline variants syntax · edacdbfa
    Łukasz Strzałkowski authored
    In most cases, when setting variant specific code, you're not sharing any code
    within format.
    
    Inline syntax can vastly simplify defining variants in those situations:
    
      respond_to do |format|
        format.js { render "trash" }
        format.html do |variant|
          variant.phone { redirect_to progress_path }
          variant.none  { render "trash" }
        end
      end
    
    Becomes:
    
      respond_to do |format|
        format.js         { render "trash" }
        format.html.phone { redirect_to progress_path }
        format.html.none  { render "trash" }
      end
    edacdbfa
    Inline variants syntax
    Łukasz Strzałkowski authored
    In most cases, when setting variant specific code, you're not sharing any code
    within format.
    
    Inline syntax can vastly simplify defining variants in those situations:
    
      respond_to do |format|
        format.js { render "trash" }
        format.html do |variant|
          variant.phone { redirect_to progress_path }
          variant.none  { render "trash" }
        end
      end
    
    Becomes:
    
      respond_to do |format|
        format.js         { render "trash" }
        format.html.phone { redirect_to progress_path }
        format.html.none  { render "trash" }
      end
Loading