-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
368 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--colour |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
body { | ||
background-color: #fff; | ||
color: #333; | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; } | ||
|
||
p, ol, ul, td { | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; } | ||
|
||
pre { | ||
background-color: #eee; | ||
padding: 10px; | ||
font-size: 11px; } | ||
|
||
a { | ||
color: #000; | ||
&:visited { | ||
color: #666; } | ||
&:hover { | ||
color: #fff; | ||
background-color: #000; } } | ||
|
||
div { | ||
&.field, &.actions { | ||
margin-bottom: 10px; } } | ||
|
||
#notice { | ||
color: green; } | ||
|
||
.field_with_errors { | ||
padding: 2px; | ||
background-color: red; | ||
display: table; } | ||
|
||
#error_explanation { | ||
width: 450px; | ||
border: 2px solid red; | ||
padding: 7px; | ||
padding-bottom: 0; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px; | ||
margin-bottom: 0px; | ||
background-color: #c00; | ||
color: #fff; } | ||
ul li { | ||
font-size: 12px; | ||
list-style: square; } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the stories controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
class StoriesController < ApplicationController | ||
# GET /stories | ||
# GET /stories.json | ||
def index | ||
@stories = Story.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render json: @stories } | ||
end | ||
end | ||
|
||
# GET /stories/1 | ||
# GET /stories/1.json | ||
def show | ||
@story = Story.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render json: @story } | ||
end | ||
end | ||
|
||
# GET /stories/new | ||
# GET /stories/new.json | ||
def new | ||
@story = Story.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render json: @story } | ||
end | ||
end | ||
|
||
# GET /stories/1/edit | ||
def edit | ||
@story = Story.find(params[:id]) | ||
end | ||
|
||
# POST /stories | ||
# POST /stories.json | ||
def create | ||
@story = Story.new(params[:story]) | ||
|
||
respond_to do |format| | ||
if @story.save | ||
format.html { redirect_to @story, notice: 'Story was successfully created.' } | ||
format.json { render json: @story, status: :created, location: @story } | ||
else | ||
format.html { render action: "new" } | ||
format.json { render json: @story.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /stories/1 | ||
# PUT /stories/1.json | ||
def update | ||
@story = Story.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @story.update_attributes(params[:story]) | ||
format.html { redirect_to @story, notice: 'Story was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: "edit" } | ||
format.json { render json: @story.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /stories/1 | ||
# DELETE /stories/1.json | ||
def destroy | ||
@story = Story.find(params[:id]) | ||
@story.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to stories_url } | ||
format.json { head :no_content } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module StoriesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Story < ActiveRecord::Base | ||
attr_accessible :content, :story_id, :twitter_handle | ||
validates_presence_of :twitter_handle | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<%= form_for(@story) do |f| %> | ||
<% if @story.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@story.errors.count, "error") %> prohibited this story from being saved:</h2> | ||
|
||
<ul> | ||
<% @story.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :content %><br /> | ||
<%= f.text_area :content %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :twitter_handle %><br /> | ||
<%= f.text_field :twitter_handle %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :story_id %><br /> | ||
<%= f.number_field :story_id %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing story</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Show', @story %> | | ||
<%= link_to 'Back', stories_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<h1>Listing stories</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Content</th> | ||
<th>Twitter handle</th> | ||
<th>Story</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
|
||
<% @stories.each do |story| %> | ||
<tr> | ||
<td><%= story.content %></td> | ||
<td><%= story.twitter_handle %></td> | ||
<td><%= story.story_id %></td> | ||
<td><%= link_to 'Show', story %></td> | ||
<td><%= link_to 'Edit', edit_story_path(story) %></td> | ||
<td><%= link_to 'Destroy', story, confirm: 'Are you sure?', method: :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New Story', new_story_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New story</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Back', stories_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<b>Content:</b> | ||
<%= @story.content %> | ||
</p> | ||
|
||
<p> | ||
<b>Twitter handle:</b> | ||
<%= @story.twitter_handle %> | ||
</p> | ||
|
||
<p> | ||
<b>Story:</b> | ||
<%= @story.story_id %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_story_path(@story) %> | | ||
<%= link_to 'Back', stories_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class CreateStories < ActiveRecord::Migration | ||
def change | ||
create_table :stories do |t| | ||
t.text :content | ||
t.string :twitter_handle | ||
t.integer :story_id | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :stories, :twitter_handle | ||
add_index :stories, :story_id | ||
add_index :stories, :created_at | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# encoding: UTF-8 | ||
# This file is auto-generated from the current state of the database. Instead | ||
# of editing this file, please use the migrations feature of Active Record to | ||
# incrementally modify your database, and then regenerate this schema definition. | ||
# | ||
# Note that this schema.rb definition is the authoritative source for your | ||
# database schema. If you need to create the application database on another | ||
# system, you should be using db:schema:load, not running all the migrations | ||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations | ||
# you'll amass, the slower it'll run and the greater likelihood for issues). | ||
# | ||
# It's strongly recommended to check this file into your version control system. | ||
|
||
ActiveRecord::Schema.define(:version => 20120426025626) do | ||
|
||
create_table "stories", :force => true do |t| | ||
t.text "content" | ||
t.string "twitter_handle" | ||
t.integer "story_id" | ||
t.datetime "created_at", :null => false | ||
t.datetime "updated_at", :null => false | ||
end | ||
|
||
add_index "stories", ["created_at"], :name => "index_stories_on_created_at" | ||
add_index "stories", ["story_id"], :name => "index_stories_on_story_id" | ||
add_index "stories", ["twitter_handle"], :name => "index_stories_on_twitter_handle" | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'spec_helper' | ||
|
||
describe Story do | ||
context "when performing validations" do | ||
it "should not be valid without a twitter handle" do | ||
story = Story.new | ||
story.should be_invalid | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'spec_helper' | ||
|
||
describe "Stories" do | ||
describe "GET /stories" do | ||
it "works! (now write some real specs)" do | ||
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers | ||
get stories_path | ||
response.status.should be(200) | ||
end | ||
end | ||
end |
Oops, something went wrong.