Skip to content

Commit

Permalink
preparing dummy app
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuberdeau committed Jul 3, 2013
1 parent 15baddf commit ac11843
Show file tree
Hide file tree
Showing 25 changed files with 535 additions and 1 deletion.
2 changes: 2 additions & 0 deletions spec/dummy/app/assets/javascripts/articles.js
@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
4 changes: 4 additions & 0 deletions spec/dummy/app/assets/stylesheets/articles.css
@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
56 changes: 56 additions & 0 deletions spec/dummy/app/assets/stylesheets/scaffold.css
@@ -0,0 +1,56 @@
body { background-color: #fff; color: #333; }

body, 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; }
a:visited { color: #666; }
a:hover { color: #fff; background-color:#000; }

div.field, div.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;
}

#error_explanation 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;
}

#error_explanation ul li {
font-size: 12px;
list-style: square;
}
58 changes: 58 additions & 0 deletions spec/dummy/app/controllers/articles_controller.rb
@@ -0,0 +1,58 @@
class ArticlesController < ApplicationController
before_action :set_article, only: [:show, :edit, :update, :destroy]

# GET /articles
def index
@articles = Article.all
end

# GET /articles/1
def show
end

# GET /articles/new
def new
@article = Article.new
end

# GET /articles/1/edit
def edit
end

# POST /articles
def create
@article = Article.new(article_params)

if @article.save
redirect_to @article, notice: 'Article was successfully created.'
else
render action: 'new'
end
end

# PATCH/PUT /articles/1
def update
if @article.update(article_params)
redirect_to @article, notice: 'Article was successfully updated.'
else
render action: 'edit'
end
end

# DELETE /articles/1
def destroy
@article.destroy
redirect_to articles_url, notice: 'Article was successfully destroyed.'
end

private
# Use callbacks to share common setup or constraints between actions.
def set_article
@article = Article.find(params[:id])
end

# Only allow a trusted parameter "white list" through.
def article_params
params.require(:article).permit(:title, :body)
end
end
2 changes: 2 additions & 0 deletions spec/dummy/app/helpers/articles_helper.rb
@@ -0,0 +1,2 @@
module ArticlesHelper
end
2 changes: 2 additions & 0 deletions spec/dummy/app/models/article.rb
@@ -0,0 +1,2 @@
class Article < ActiveRecord::Base
end
25 changes: 25 additions & 0 deletions spec/dummy/app/views/articles/_form.html.erb
@@ -0,0 +1,25 @@
<%= form_for(@article) do |f| %>
<% if @article.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@article.errors.count, "error") %> prohibited this article from being saved:</h2>

<ul>
<% @article.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :title %><br>
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :body %><br>
<%= f.text_area :body %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
6 changes: 6 additions & 0 deletions spec/dummy/app/views/articles/edit.html.erb
@@ -0,0 +1,6 @@
<h1>Editing article</h1>

<%= render 'form' %>
<%= link_to 'Show', @article %> |
<%= link_to 'Back', articles_path %>
29 changes: 29 additions & 0 deletions spec/dummy/app/views/articles/index.html.erb
@@ -0,0 +1,29 @@
<h1>Listing articles</h1>

<table>
<thead>
<tr>
<th>Title</th>
<th>Body</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>

<tbody>
<% @articles.each do |article| %>
<tr>
<td><%= article.title %></td>
<td><%= article.body %></td>
<td><%= link_to 'Show', article %></td>
<td><%= link_to 'Edit', edit_article_path(article) %></td>
<td><%= link_to 'Destroy', article, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>

<br>

<%= link_to 'New Article', new_article_path %>
5 changes: 5 additions & 0 deletions spec/dummy/app/views/articles/new.html.erb
@@ -0,0 +1,5 @@
<h1>New article</h1>

<%= render 'form' %>
<%= link_to 'Back', articles_path %>
14 changes: 14 additions & 0 deletions spec/dummy/app/views/articles/show.html.erb
@@ -0,0 +1,14 @@
<p id="notice"><%= notice %></p>

<p>
<strong>Title:</strong>
<%= @article.title %>
</p>

<p>
<strong>Body:</strong>
<%= @article.body %>
</p>

<%= link_to 'Edit', edit_article_path(@article) %> |
<%= link_to 'Back', articles_path %>
2 changes: 1 addition & 1 deletion spec/dummy/config/application.rb
Expand Up @@ -8,7 +8,7 @@
# require "rails/test_unit/railtie"

Bundler.require(*Rails.groups)
require "foobar"
require "acts_as_seo_friendly"

module Dummy
class Application < Rails::Application
Expand Down
2 changes: 2 additions & 0 deletions spec/dummy/config/routes.rb
@@ -1,4 +1,6 @@
Dummy::Application.routes.draw do
resources :articles

# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

Expand Down
Binary file added spec/dummy/db/development.sqlite3
Binary file not shown.
11 changes: 11 additions & 0 deletions spec/dummy/db/migrate/20130703005336_create_articles.rb
@@ -0,0 +1,11 @@
class CreateArticles < ActiveRecord::Migration
def change
create_table :articles do |t|
t.string :title
t.text :body

t.timestamps
end
Articles.create_seo_friendly_column()
end
end
12 changes: 12 additions & 0 deletions spec/dummy/log/development.log
@@ -0,0 +1,12 @@
 (29.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
 (5.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
Migrating to CreateArticles (20130703005336)
 (0.1ms) begin transaction
 (0.6ms) CREATE TABLE "articles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "body" text, "created_at" datetime, "updated_at" datetime) 
 (0.0ms) rollback transaction
ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
Migrating to CreateArticles (20130703005336)
 (0.1ms) begin transaction
 (0.5ms) CREATE TABLE "articles" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "body" text, "created_at" datetime, "updated_at" datetime) 
 (0.2ms) rollback transaction

0 comments on commit ac11843

Please sign in to comment.