Skip to content
Browse files

Named routes added

  • Loading branch information...
1 parent cd9ab60 commit 46530be016d2dc781b3485b22f6e441c8debd795 @safalmj committed Aug 26, 2012
View
4 app/views/layouts/_footer.html.erb
@@ -5,8 +5,8 @@
</small>
<nav>
<ul>
- <li><%= link_to "About", '#' %></li>
- <li><%= link_to "Contact", '#' %></li>
+ <li><%= link_to "About", about_path %></li>
+ <li><%= link_to "Contact", contact_path %></li>
<li><a href="http://news.railstutorial.org/">News</a></li>
</ul>
</nav>
View
6 app/views/layouts/_header.html.erb
@@ -1,11 +1,11 @@
<header class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
- <%= link_to "sample app", '#', :id => "logo" %>
+ <%= link_to "sample app", root_path, :id => "logo" %>
<nav>
<ul class="nav pull-right">
- <li><%= link_to "Home", '#' %></li>
- <li><%= link_to "Help", '#' %></li>
+ <li><%= link_to "Home", root_path %></li>
+ <li><%= link_to "Help", help_path %></li>
<li><%= link_to "Sign in", '#' %></li>
</ul>
</nav>
View
10 config/routes.rb
@@ -1,9 +1,9 @@
SampleApp::Application.routes.draw do
- root :to => "staticPages#home"
- get "static_pages/home"
- get "static_pages/help"
- get "/static_pages/about"
- get "/static_pages/contact"
+ root :to => "static_pages#home"
+
+ match "/help", :to => "static_pages#help"
+ match "/about", :to => "static_pages#about"
+ match "/contact", :to => "static_pages#contact"
# The priority is based upon order of creation:
# first created -> highest priority.
View
18 spec/requests/static_pages_spec.rb
@@ -5,56 +5,56 @@
describe "Home page" do
it "should have the h1 'Sample App'" do
- visit '/static_pages/home'
+ visit root_path
#page.should have_content('Sample App')
page.should have_selector('h1',
:text => 'Sample App')
end
it "should have the title 'Home'" do
- visit '/static_pages/home'
+ visit root_path
page.should have_selector('title',
:text => "#{base_title} | Home")
end
end
describe "Help page" do
it "should have the h1 'Help'" do
- visit '/static_pages/help'
+ visit help_path
page.should have_selector('h1',
:text => 'Help')
end
it "should have the title 'Help'" do
- visit '/static_pages/help'
+ visit help_path
page.should have_selector('title',
:text => "#{base_title} | Help")
end
end
describe "About Us" do
it "should have the h1 'About us'" do
- visit "/static_pages/about"
+ visit about_path
page.should have_selector('h1',
:text => "About")
end
it "should have the title 'About Us'" do
- visit "/static_pages/about"
+ visit about_path
page.should have_selector('title',
- :text =>"#{base_title} | About")
+ :text => "#{base_title} | About")
end
end
describe "Contact Page" do
it "should have the h1 'Contact'" do
- visit "/static_pages/contact"
+ visit contact_path
page.should have_selector('h1',
:text => "Contact")
end
it "should have the title 'Contact'" do
- visit "/static_pages/contact"
+ visit contact_path
page.should have_selector('title',
:text => "#{base_title} | Contact")
end

0 comments on commit 46530be

Please sign in to comment.
Something went wrong with that request. Please try again.