Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 11 files changed
  • 0 comments
  • 1 contributor
3  app/assets/javascripts/pages.js.coffee
... ...
@@ -0,0 +1,3 @@
  1
+# Place all the behaviors and hooks related to the matching controller here.
  2
+# All this logic will automatically be available in application.js.
  3
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3  app/assets/stylesheets/pages.css.scss
... ...
@@ -0,0 +1,3 @@
  1
+// Place all the styles related to the Pages controller here.
  2
+// They will automatically be included in application.css.
  3
+// You can use Sass (SCSS) here: http://sass-lang.com/
13  app/controllers/pages_controller.rb
... ...
@@ -0,0 +1,13 @@
  1
+class PagesController < ApplicationController
  2
+  def home
  3
+    @title = "Home"
  4
+  end
  5
+
  6
+  def contact
  7
+    @title = "Contact"
  8
+  end
  9
+
  10
+  def about
  11
+    @title = "About"
  12
+  end
  13
+end
2  app/helpers/pages_helper.rb
... ...
@@ -0,0 +1,2 @@
  1
+module PagesHelper
  2
+end
9  app/views/layouts/application.html.erb
... ...
@@ -1,14 +1,11 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3 3
 <head>
4  
-  <title>SampleApp</title>
5  
-  <%= stylesheet_link_tag    "application", :media => "all" %>
6  
-  <%= javascript_include_tag "application" %>
7  
-  <%= csrf_meta_tags %>
  4
+<title>Ruby on Rails Tutorial Sample App | <%= @title %></title>
  5
+<%= csrf_meta_tag %>
8 6
 </head>
9 7
 <body>
10  
-
11 8
 <%= yield %>
12  
-
13 9
 </body>
14 10
 </html>
  11
+
8  app/views/pages/about.html.erb
... ...
@@ -0,0 +1,8 @@
  1
+<h1>About Us</h1>
  2
+<p>
  3
+<a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
  4
+is a project to make a book and screencasts to teach web development
  5
+with <a href="http://rubyonrails.org/">Ruby on Rails</a>. This
  6
+is the sample application for the tutorial.
  7
+</p>
  8
+
7  app/views/pages/contact.html.erb
... ...
@@ -0,0 +1,7 @@
  1
+
  2
+<h1>Contact</h1>
  3
+<p>
  4
+Contact Ruby on Rails Tutorial about the sample app at the
  5
+<a href="http://railstutorial.org/feedback">feedback page</a>.
  6
+</p>
  7
+
7  app/views/pages/home.html.erb
... ...
@@ -0,0 +1,7 @@
  1
+<h1>Sample App</h1>
  2
+<p>
  3
+This is the home page for the
  4
+<a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
  5
+sample application.
  6
+</p>
  7
+
5  config/routes.rb
... ...
@@ -1,4 +1,9 @@
1 1
 SampleApp::Application.routes.draw do
  2
+  get "pages/home"
  3
+
  4
+  get "pages/contact"
  5
+
  6
+  get "pages/about"
2 7
   # The priority is based upon order of creation:
3 8
   # first created -> highest priority.
4 9
 
16  db/schema.rb
... ...
@@ -0,0 +1,16 @@
  1
+# encoding: UTF-8
  2
+# This file is auto-generated from the current state of the database. Instead
  3
+# of editing this file, please use the migrations feature of Active Record to
  4
+# incrementally modify your database, and then regenerate this schema definition.
  5
+#
  6
+# Note that this schema.rb definition is the authoritative source for your
  7
+# database schema. If you need to create the application database on another
  8
+# system, you should be using db:schema:load, not running all the migrations
  9
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
  10
+# you'll amass, the slower it'll run and the greater likelihood for issues).
  11
+#
  12
+# It's strongly recommended to check this file into your version control system.
  13
+
  14
+ActiveRecord::Schema.define(:version => 0) do
  15
+
  16
+end
45  spec/controllers/pages_controller_spec.rb
... ...
@@ -0,0 +1,45 @@
  1
+require 'spec_helper'
  2
+
  3
+describe PagesController do
  4
+
  5
+  render_views
  6
+  describe "GET 'home'" do
  7
+    it "returns http success" do
  8
+      get 'home'
  9
+      response.should be_success
  10
+    end
  11
+
  12
+    it "should have the rigth title" do
  13
+      get 'home'
  14
+      response.should have_selector("title",
  15
+		:content => "Ruby on Rails Tutorial Sample App | Home")     
  16
+    end 			
  17
+  end
  18
+
  19
+  describe "GET 'contact'" do
  20
+    it "returns http success" do
  21
+      get 'contact'
  22
+      response.should be_success
  23
+    end
  24
+    
  25
+    it "should have the rigth title" do
  26
+      get 'contact'
  27
+      response.should have_selector("title",
  28
+		:content => "Ruby on Rails Tutorial Sample App | Contact")     
  29
+    end
  30
+  end
  31
+
  32
+  describe "GET 'about'" do
  33
+    it "returns http success" do
  34
+      get 'about'
  35
+      response.should be_success
  36
+    end
  37
+   
  38
+    it "should have the rigth title" do
  39
+      get 'about'
  40
+      response.should have_selector("title",
  41
+		:content => "Ruby on Rails Tutorial Sample App | About")     
  42
+    end
  43
+  end
  44
+
  45
+end

No commit comments for this range

Something went wrong with that request. Please try again.