• Ł
    Inline variants syntax · edacdbfa
    Łukasz Strzałkowski 提交于
    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
mime_responds.rb 18.3 KB