Adding the help action to the Pages controller in Java

Encoder Data Matrix 2d barcode in Java Adding the help action to the Pages controller
Listing 514 Adding the help action to the Pages controller
Make Data Matrix 2d Barcode In Java
Using Barcode encoder for Java Control to generate, create Data Matrix ECC200 image in Java applications.
app/controllers/pages_controllerrb
Bar Code Generation In Java
Using Barcode drawer for Java Control to generate, create barcode image in Java applications.
class PagesController < ApplicationController def help @title = "Help" end end
Recognize Barcode In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
Listing 515 Adding a view for the Help page
Drawing Data Matrix 2d Barcode In C#
Using Barcode printer for .NET Control to generate, create Data Matrix 2d barcode image in .NET framework applications.
5: Filling in the Layout
Generating Data Matrix In .NET Framework
Using Barcode drawer for ASP.NET Control to generate, create Data Matrix image in ASP.NET applications.
app/views/pages/helphtmlerb
Data Matrix ECC200 Generator In Visual Studio .NET
Using Barcode drawer for VS .NET Control to generate, create ECC200 image in .NET applications.
<h1>Help</h1> <p> Get help on Ruby on Rails Tutorial at the <a href="http://railstutorialorg/help">Rails Tutorial help page</a> To get help on this sample app, see the <a href="http://railstutorialorg/book">Rails Tutorial book</a> </p>
Data Matrix 2d Barcode Generator In Visual Basic .NET
Using Barcode encoder for Visual Studio .NET Control to generate, create DataMatrix image in .NET framework applications.
There s one final detail to deal with before moving on: if you re running Autotest, you might notice that it doesn t run the integration test This is by design, since integration tests can be slow and hence can disrupt the red-green-refactor cycle, but I still find it preferable to have Autotest run the integration tests To arrange for this to happen, you just have to tell Autotest to run tests in the spec/requests directory (Listing 516 or Listing 517)
Make Code 128C In Java
Using Barcode drawer for Java Control to generate, create Code 128 image in Java applications.
Listing 516 Additions to autotest needed to run integration tests with Autotest on OS X
Draw Code-39 In Java
Using Barcode creation for Java Control to generate, create Code 39 Extended image in Java applications.
Autotestadd_hook :initialize do |autotest| autotestadd_mapping(/ spec\/requests\/*_spec\rb$/) do autotestfiles_matching(/ spec\/requests\/*_spec\rb$/) end end
Make GTIN - 13 In Java
Using Barcode generation for Java Control to generate, create EAN13 image in Java applications.
Listing 517 Additions to autotest needed to run integration tests with Autotest on Ubuntu Linux
DataMatrix Encoder In Java
Using Barcode creation for Java Control to generate, create DataMatrix image in Java applications.
Autotestadd_hook :initialize do |autotest| autotestadd_mapping(%r% spec/(requests)/*rb$%) do|filename, _| filename end end
Encode Barcode In Java
Using Barcode generation for Java Control to generate, create bar code image in Java applications.
Don t worry about where this code comes from; I don t know the Autotest API either At some point I Googled around with search terms like rspec autotest integration and found it, and when I dropped it into my autotest file, it worked
USS Code 93 Maker In Java
Using Barcode generator for Java Control to generate, create Code 9/3 image in Java applications.
Layout Links
Making Barcode In Visual Studio .NET
Using Barcode generation for ASP.NET Control to generate, create bar code image in ASP.NET applications.
522 Rails Routes
Data Matrix Encoder In Visual Basic .NET
Using Barcode printer for Visual Studio .NET Control to generate, create ECC200 image in Visual Studio .NET applications.
Now that we have tests for the URLs we want, it s time to get them to work As noted in Section 312, the file Rails uses for URL mappings is config/routesrb If you take a look at the default routes file, you ll see that it s quite a mess, but it s a useful mess full of commented-out example route mappings I suggest reading through it at some point, and also taking a look at the Rails Guides article Rails Routing from the outside in for a much more in-depth treatment of routes For now, though, we ll stick with the examples in Listing 5189
EAN / UCC - 13 Generation In .NET
Using Barcode creator for Visual Studio .NET Control to generate, create UPC - 13 image in Visual Studio .NET applications.
Listing 518 Routes for static pages
Drawing Bar Code In Visual Studio .NET
Using Barcode generator for Visual Studio .NET Control to generate, create bar code image in VS .NET applications.
config/routesrb
Data Matrix 2d Barcode Decoder In .NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
SampleApp::Applicationroutesdraw do match '/contact', :to => 'pages#contact' match '/about', :to => 'pages#about' match '/help', :to => 'pages#help' end
Encode Code 128B In Visual C#
Using Barcode creator for .NET Control to generate, create Code 128A image in Visual Studio .NET applications.
If you read this code carefully, you can probably figure out what it does; for example, you can see that
Making Code 3/9 In VS .NET
Using Barcode creation for VS .NET Control to generate, create Code 39 Full ASCII image in Visual Studio .NET applications.
match '/about', :to => 'pages#about'
matches /about and routes it to the about action in the Pages controller Before, this was more explicit: we used get 'pages/about' to get to the same place, but /about is more succinct What isn t obvious is that match /about also automatically creates named routes for use in the controllers and views:
about_path => '/about' about_url => 'http://localhost:3000/about'
9 In the line SampleApp::Applicationroutesdraw do you might recognize that the draw method takes a block, a construction we last saw in Section 432
5: Filling in the Layout
Note that about_url is the full URL http://localhost:3000/about (with localhost:3000 being replaced with the domain name, such as examplecom, for a fully
deployed site) As discussed in Section 52, to get just /about, you use about_path (Rails Tutorial uses the path form for consistency, but the difference rarely matters in practice) With these routes now defined, the tests for the About, Contact, and Help pages should pass (As usual, use Autotest or rspec spec/ to check) This leaves the test for the Home page To establish the route mapping for the Home page, we could use code like this:
match '/', :to => 'pages#home'
This is unnecessary, though; Rails has special instructions for the root URL / ( slash ) located lower down in the file (Listing 519)
Listing 519 The commented-out hint for defining the root route
config/routesrb
SampleApp::Applicationroutesdraw do # You can have the root of your site routed with "root" # just remember to delete public/indexhtml # root :to => "welcome#index" end
Using Listing 519 as a model, we arrive at Listing 520 to route the root URL / to the Home page
Listing 520 Adding a mapping for the root route
config/routesrb
SampleApp::Applicationroutesdraw do match '/contact', :to => 'pages#contact' match '/about', :to => 'pages#about' match '/help', :to => 'pages#help'
Layout Links
root :to => 'pages#home' end
This code maps the root URL / to /pages/home, and also gives URL helpers as follows:
root_path => '/' root_url => 'http://localhost:3000/'
We should also heed the comment in Listing 519 and delete public/indexhtml to prevent Rails from rendering the default page (Figure 13) when we visit / You can of course simply remove the file by trashing it, but if you re using Git for version control there s a way to tell Git about the removal at the same time using git rm:
$ git rm public/indexhtml $ git commit -am "Removed default Rails page"
With that, all of the routes for static pages are working, and the tests should pass Now we just have to fill in the links in the layout