2: Anatomy of a Web Application




Learning Rails show

Summary: To listen to the lesson, click the Play button on the left. You can also right-click on the download link to save the mp3 file, or you can subscribe in iTunes (just search for Learning Rails). <p> </p> <p>To read a transcript of the lesson, click the Transcript link on the left.</p> <p><strong>The heart of the lesson is the audio</strong>; these notes are supplementary. So please listen to the audio, or read the transcript, before making use of these notes.</p> <h2>Examples used in the audio program</h2> <p>Here’s some of the examples we use in the show, which may be easier to grasp in printed form:</p> <ul> <li>If the user types www.BuildingWebApps.com/podcast.html into their browser, they’re asking the server at BuildingWebApps.com to find a file called podcast.html and send the contents of that file to the browser.</li> <li>In a Rails application, the request would be written as www.BuildingWebApps.com/podcast, in which podcast is the name of the controller to be invoked</li> <li>A Rails <span class="caps">URL</span> such as www.BuildingWebApps.com/podcast/show/17 invokes the show action in the podcast controller and passes it the parameter of 17 (presumably the ID for a podcast episode).</li> <li>To request all the podcast objects, the controller would execute a statement such as <code>podcasts = Podcast.find(:all)</code>. (Don’t worry about the odd punctuation for now.</li> <li>To find a particular podcast episode according to its episode number, the show action might execute a statement such as <code>podcast = Podcast.find_by_episode(2)</code> </li> </ul> <h2>For More Information</h2> <p>See the notes for <a href="/podcasts/79326-why-you-should-learn-ruby-on/24793-show-notes">Lesson 1</a> for pointers to online resources and books about Ruby and Ruby on Rails.</p>