Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9833: render_json_docfix.diff

File render_json_docfix.diff, 2.3 kB (added by chuyeow, 9 months ago)
  • actionpack/lib/action_controller/base.rb

    old new  
    748748      # 
    749749      # === Rendering JSON 
    750750      # 
    751       # Rendering JSON sets the content type to text/x-json and optionally wraps the JSON in a callback. It is expected 
    752       # that the response will be eval'd for use as a data structure. 
     751      # Rendering JSON sets the content type to application/json and optionally wraps the JSON in a callback. It is expected 
     752      # that the response will be parsed (or eval'd) for use as a data structure. 
    753753      # 
    754       #   # Renders '{name: "David"}' 
     754      #   # Renders '{"name": "David"}' 
    755755      #   render :json => {:name => "David"}.to_json 
    756756      # 
     757      # It's not necessary to call <tt>to_json</tt> on the object you want to render, since <tt>render</tt> will 
     758      # automatically do that for you: 
     759      # 
     760      #   # Also renders '{"name": "David"}' 
     761      #   render :json => {:name => "David"} 
     762      # 
    757763      # Sometimes the result isn't handled directly by a script (such as when the request comes from a SCRIPT tag), 
    758       # so the callback option is provided for these cases. 
     764      # so the <tt>:callback</tt> option is provided for these cases. 
    759765      # 
    760       #   # Renders 'show({name: "David"})' 
     766      #   # Renders 'show({"name": "David"})' 
    761767      #   render :json => {:name => "David"}.to_json, :callback => 'show' 
    762768      # 
    763769      # === Rendering an inline template 
  • actionpack/lib/action_controller/mime_type.rb

    old new  
    5252        EXTENSION_LOOKUP[extension] 
    5353      end 
    5454 
    55       # Registers an alias that's not usd on mime type lookup, but can be referenced directly. Especially useful for 
     55      # Registers an alias that's not used on mime type lookup, but can be referenced directly. Especially useful for 
    5656      # rendering different HTML versions depending on the user agent, like an iPhone. 
    5757      def register_alias(string, symbol, extension_synonyms = []) 
    5858        register(string, symbol, [], extension_synonyms, true)