Test Your Knowledge

Quiz

  1. How much JavaScript do you need to write to create Ajax applications from Rails?

  2. What is the difference between form_tag and form_remote_tag?

  3. What helper method lets you place identifiers on data on a per-record basis?

  4. How do you include the Prototype and Script.aculo.us JavaScript libraries in your pages?

  5. Which object lets you create JavaScript using Ruby in RJS pages?

Answers

  1. You can create a basic Ajax application using Rails without writing any JavaScript directly. If you want to do complex things in the browser, though, you may find it easier to write some JavaScript.

  2. form_tag issues an HTTP request that replaces all the content in the browser. form_remote_tag issues an HTTP request, but processes the results with JavaScript rather than having the browser render them directly.

  3. The dom_id helper lets you put identifiers into HTML documents and reference them from your server code as well.

  4. Putting <%= javascript_include_tag :defaults %> into a view will load the Prototype and Script.aculo.us JavaScript libraries into the resulting HTML document.

  5. The page object is the bridge between Ruby and JavaScript code.

Get Learning Rails: Live Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.