Skip to content
Browse files

scaffold model using cache_money

  • Loading branch information...
1 parent 212a204 commit 090fe63ec86fca7b50a78d637f0803075f186705 Oren Teich committed May 17, 2010
View
1 Gemfile
@@ -4,6 +4,7 @@ gem 'cache-money'
gem 'memcached'
group :development do
+ gem 'memcache-client', :require => 'MemCache'
gem 'sqlite3-ruby', :require => 'sqlite3'
end
View
85 app/controllers/users_controller.rb
@@ -0,0 +1,85 @@
+class UsersController < ApplicationController
+ # GET /users
+ # GET /users.xml
+ def index
+ @users = User.all
+ @count = User.count
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @users }
+ end
+ end
+
+ # GET /users/1
+ # GET /users/1.xml
+ def show
+ @user = User.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @user }
+ end
+ end
+
+ # GET /users/new
+ # GET /users/new.xml
+ def new
+ @user = User.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @user }
+ end
+ end
+
+ # GET /users/1/edit
+ def edit
+ @user = User.find(params[:id])
+ end
+
+ # POST /users
+ # POST /users.xml
+ def create
+ @user = User.new(params[:user])
+
+ respond_to do |format|
+ if @user.save
+ flash[:notice] = 'User was successfully created.'
+ format.html { redirect_to(@user) }
+ format.xml { render :xml => @user, :status => :created, :location => @user }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /users/1
+ # PUT /users/1.xml
+ def update
+ @user = User.find(params[:id])
+
+ respond_to do |format|
+ if @user.update_attributes(params[:user])
+ flash[:notice] = 'User was successfully updated.'
+ format.html { redirect_to(@user) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /users/1
+ # DELETE /users/1.xml
+ def destroy
+ @user = User.find(params[:id])
+ @user.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(users_url) }
+ format.xml { head :ok }
+ end
+ end
+end
View
2 app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
View
3 app/models/user.rb
@@ -0,0 +1,3 @@
+class User < ActiveRecord::Base
+ index :name
+end
View
17 app/views/layouts/users.html.erb
@@ -0,0 +1,17 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
+ <title>Users: <%= controller.action_name %></title>
+ <%= stylesheet_link_tag 'scaffold' %>
+</head>
+<body>
+
+<p style="color: green"><%= flash[:notice] %></p>
+
+<%= yield %>
+
+</body>
+</html>
View
20 app/views/users/edit.html.erb
@@ -0,0 +1,20 @@
+<h1>Editing user</h1>
+
+<% form_for(@user) do |f| %>
+ <%= f.error_messages %>
+
+ <p>
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </p>
+ <p>
+ <%= f.label :age %><br />
+ <%= f.text_field :age %>
+ </p>
+ <p>
+ <%= f.submit 'Update' %>
+ </p>
+<% end %>
+
+<%= link_to 'Show', @user %> |
+<%= link_to 'Back', users_path %>
View
23 app/views/users/index.html.erb
@@ -0,0 +1,23 @@
+<h1>Listing users</h1>
+
+<%= @count %> users total
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Age</th>
+ </tr>
+
+<% @users.each do |user| %>
+ <tr>
+ <td><%=h user.name %></td>
+ <td><%=h user.age %></td>
+ <td><%= link_to 'Show', user %></td>
+ <td><%= link_to 'Edit', edit_user_path(user) %></td>
+ <td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New user', new_user_path %>
View
19 app/views/users/new.html.erb
@@ -0,0 +1,19 @@
+<h1>New user</h1>
+
+<% form_for(@user) do |f| %>
+ <%= f.error_messages %>
+
+ <p>
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </p>
+ <p>
+ <%= f.label :age %><br />
+ <%= f.text_field :age %>
+ </p>
+ <p>
+ <%= f.submit 'Create' %>
+ </p>
+<% end %>
+
+<%= link_to 'Back', users_path %>
View
13 app/views/users/show.html.erb
@@ -0,0 +1,13 @@
+<p>
+ <b>Name:</b>
+ <%=h @user.name %>
+</p>
+
+<p>
+ <b>Age:</b>
+ <%=h @user.age %>
+</p>
+
+
+<%= link_to 'Edit', edit_user_path(@user) %> |
+<%= link_to 'Back', users_path %>
View
12 config/boot.rb
@@ -109,18 +109,14 @@ def read_environment_rb
class Rails::Boot
def run
load_initializer
- extend_environment
- Rails::Initializer.run(:set_load_path)
- end
- def extend_environment
Rails::Initializer.class_eval do
- old_load = instance_method(:load_environment)
- define_method(:load_environment) do
- Bundler.require Rails.env, :plugins
- old_load.bind(self).call
+ def load_gems
+ @bundler_loaded ||= Bundler.require :default, Rails.env
end
end
+
+ Rails::Initializer.run(:set_load_path)
end
end
View
2 config/environments/development.rb
@@ -14,4 +14,4 @@
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
-config.action_mailer.raise_delivery_errors = false
+config.action_mailer.raise_delivery_errors = false
View
15 config/environments/production.rb
@@ -7,17 +7,4 @@
# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching = true
-config.action_view.cache_template_loading = true
-
-config.cache_store = :mem_cache_store, Memcached::Rails.new
-
-require 'cache_money'
-$memcache = Memcached.new
-
-$local = Cash::Local.new($memcache)
-$lock = Cash::Lock.new($memcache)
-$cache = Cash::Transactional.new($local, $lock)
-
-class ActiveRecord::Base
- is_cached :repository => $cache
-end
+config.action_view.cache_template_loading = true
View
15 config/initializers/cache_money.rb
@@ -0,0 +1,15 @@
+require 'cache_money'
+
+if RAILS_ENV == "production"
+ $memcache = Memcached.new
+else
+ $memcache = MemCache.new 'localhost:11211'
+end
+
+$local = Cash::Local.new($memcache)
+$lock = Cash::Lock.new($memcache)
+$cache = Cash::Transactional.new($local, $lock)
+
+class ActiveRecord::Base
+ is_cached :repository => $cache
+end
View
33 config/preinitializer.rb
@@ -1,23 +1,20 @@
begin
- # Set up load paths for the locked set of pre-resolved gems.
- require File.expand_path('../../.bundle/environment', __FILE__)
-rescue LoadError
- # Fall back on trying to resolve out of already-installed gems at runtime.
require "rubygems"
require "bundler"
+rescue LoadError
+ raise "Could not load the bundler gem. Install it with `gem install bundler`."
+end
- if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.5")
- raise RuntimeError,
- "Your bundler version is incompatible with Rails 2.3 and an unlocked bundle.\n" +
- "Run `gem install bundler` to upgrade or `bundle lock` to lock."
- end
-
- begin
- # Set up load paths for all bundled gems
- Bundler.setup
- # Require all gems not in a group
- Bundler.require :default
- rescue Bundler::GemNotFound
- raise Bundler::GemNotFound, "Bundler couldn't find some gems. Did you run `bundle install`?"
- end
+if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
+ raise RuntimeError, "Your bundler version is too old." +
+ "Run `gem install bundler` to upgrade."
end
+
+begin
+ # Set up load paths for all bundled gems
+ ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
+ Bundler.setup
+rescue Bundler::GemNotFound
+ raise RuntimeError, "Bundler couldn't find some gems." +
+ "Did you run `bundle install`?"
+end
View
2 config/routes.rb
@@ -1,4 +1,6 @@
ActionController::Routing::Routes.draw do |map|
+ map.resources :users
+
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
View
BIN db/development.sqlite3
Binary file not shown.
View
14 db/migrate/20100518013215_create_users.rb
@@ -0,0 +1,14 @@
+class CreateUsers < ActiveRecord::Migration
+ def self.up
+ create_table :users do |t|
+ t.string :name
+ t.integer :age
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :users
+ end
+end
View
21 db/schema.rb
@@ -0,0 +1,21 @@
+# 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 => 20100518013215) do
+
+ create_table "users", :force => true do |t|
+ t.string "name"
+ t.integer "age"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+end
View
169 log/development.log
@@ -0,0 +1,169 @@
+
+
+Processing UsersController#index (for 127.0.0.1 at 2010-05-17 18:33:58) [GET]
+ SQL (0.3ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.1ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+
+NoMethodError (undefined method `index' for User(Table doesn't exist):Class):
+ app/models/user.rb:2
+ app/controllers/users_controller.rb:5:in `index'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (36.1ms)
+Rendered rescues/_request_and_response (1.0ms)
+Rendering rescues/layout (internal_server_error)
+ SQL (0.3ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.2ms) select sqlite_version(*)
+ SQL (11.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
+ SQL (13.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
+ SQL (0.2ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.1ms) SELECT version FROM schema_migrations
+Migrating to CreateUsers (20100518013215)
+ SQL (0.5ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "age" integer, "created_at" datetime, "updated_at" datetime) 
+ SQL (0.1ms) INSERT INTO schema_migrations (version) VALUES ('20100518013215')
+ SQL (0.2ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.1ms) SELECT version FROM schema_migrations
+ SQL (0.1ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.0ms) PRAGMA index_list("users")
+
+
+Processing UsersController#index (for 127.0.0.1 at 2010-05-17 18:34:46) [GET]
+ SQL (0.5ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.1ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+
+NoMethodError (undefined method `index' for #<Class:0x1056792a0>):
+ app/models/user.rb:2
+ app/controllers/users_controller.rb:5:in `index'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (29.2ms)
+Rendered rescues/_request_and_response (1.0ms)
+Rendering rescues/layout (internal_server_error)
+
+
+Processing ApplicationController#index (for 127.0.0.1 at 2010-05-17 18:35:02) [GET]
+
+ActionController::RoutingError (No route matches "/user" with {:method=>:get}):
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendering rescues/layout (not_found)
+
+
+Processing UsersController#index (for 127.0.0.1 at 2010-05-17 18:35:04) [GET]
+ SQL (0.4ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+ SQL (0.2ms)  SELECT name
+ FROM sqlite_master
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
+
+
+NoMethodError (undefined method `index' for #<Class:0x1053fb258>):
+ app/models/user.rb:2
+ app/controllers/users_controller.rb:5:in `index'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:162:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:95:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:92:in `each'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:92:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:23:in `start'
+ /Users/oren/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/webrick/server.rb:82:in `start'
+
+Rendered rescues/_trace (31.1ms)
+Rendered rescues/_request_and_response (0.3ms)
+Rendering rescues/layout (internal_server_error)
+DEPRECATION WARNING: require "activesupport" is deprecated and will be removed in Rails 3. Use require "active_support" instead.. (called from /Users/oren/.rvm/gems/ruby-1.8.7-p249@rails2/gems/activesupport-2.3.5/lib/activesupport.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead.. (called from /Users/oren/.rvm/gems/ruby-1.8.7-p249@rails2/gems/activerecord-2.3.5/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activesupport" is deprecated and will be removed in Rails 3. Use require "active_support" instead.. (called from /Users/oren/.rvm/gems/ruby-1.8.7-p249@rails2/gems/activesupport-2.3.5/lib/activesupport.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead.. (called from /Users/oren/.rvm/gems/ruby-1.8.7-p249@rails2/gems/activerecord-2.3.5/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activesupport" is deprecated and will be removed in Rails 3. Use require "active_support" instead.. (called from /Users/oren/.rvm/gems/ruby-1.8.7-p249@rails2/gems/activesupport-2.3.5/lib/activesupport.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead.. (called from /Users/oren/.rvm/gems/ruby-1.8.7-p249@rails2/gems/activerecord-2.3.5/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activesupport" is deprecated and will be removed in Rails 3. Use require "active_support" instead.. (called from /Users/oren/.rvm/gems/ruby-1.8.7-p249@rails2/gems/activesupport-2.3.5/lib/activesupport.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead.. (called from /Users/oren/.rvm/gems/ruby-1.8.7-p249@rails2/gems/activerecord-2.3.5/lib/activerecord.rb:2)
+DEPRECATION WARNING: require "activesupport" is deprecated and will be removed in Rails 3. Use require "active_support" instead.. (called from /Users/oren/.rvm/gems/ruby-1.8.7-p249@rails2/gems/activesupport-2.3.5/lib/activesupport.rb:2)
+DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead.. (called from /Users/oren/.rvm/gems/ruby-1.8.7-p249@rails2/gems/activerecord-2.3.5/lib/activerecord.rb:2)
+
+
+Processing UsersController#index (for 127.0.0.1 at 2010-05-17 18:47:10) [GET]
+ User Load (0.4ms) SELECT * FROM "users" 
+ SQL (0.1ms) SELECT count(*) AS count_all FROM "users" 
+Rendering template within layouts/users
+Rendering users/index
+Completed in 589ms (View: 584, DB: 1) | 200 OK [http://localhost/users]
+
+
+Processing UsersController#new (for 127.0.0.1 at 2010-05-17 18:47:14) [GET]
+Rendering template within layouts/users
+Rendering users/new
+Completed in 9ms (View: 6, DB: 0) | 200 OK [http://localhost/users/new]
+
+
+Processing UsersController#create (for 127.0.0.1 at 2010-05-17 18:47:20) [POST]
+ Parameters: {"commit"=>"Create", "authenticity_token"=>"RN8QhvHU0JAktkogoJZv1uHc7RPBvQcy572ggnXB3to=", "user"=>{"name"=>"Oren Teich", "age"=>"34"}}
+ User Create (0.3ms) INSERT INTO "users" ("name", "created_at", "updated_at", "age") VALUES('Oren Teich', '2010-05-18 01:47:20', '2010-05-18 01:47:20', 34)
+ User Load (0.2ms) SELECT id FROM "users" WHERE ("users"."name" = 'Oren Teich') 
+ SQL (0.1ms) SELECT count(*) AS count_all FROM "users" WHERE ("users"."name" = 'Oren Teich') 
+Redirected to http://localhost:3000/users/1
+Completed in 38ms (DB: 1) | 302 Found [http://localhost/users]
+
+
+Processing UsersController#show (for 127.0.0.1 at 2010-05-17 18:47:20) [GET]
+ Parameters: {"id"=>"1"}
+Rendering template within layouts/users
+Rendering users/show
+Completed in 9ms (View: 4, DB: 0) | 200 OK [http://localhost/users/1]
View
54 public/stylesheets/scaffold.css
@@ -0,0 +1,54 @@
+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; }
+
+.fieldWithErrors {
+ padding: 2px;
+ background-color: red;
+ display: table;
+}
+
+#errorExplanation {
+ width: 400px;
+ border: 2px solid red;
+ padding: 7px;
+ padding-bottom: 12px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+}
+
+#errorExplanation h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ background-color: #c00;
+ color: #fff;
+}
+
+#errorExplanation p {
+ color: #333;
+ margin-bottom: 0;
+ padding: 5px;
+}
+
+#errorExplanation ul li {
+ font-size: 12px;
+ list-style: square;
+}
+
View
9 test/fixtures/users.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+one:
+ name: MyString
+ age: 1
+
+two:
+ name: MyString
+ age: 1
View
45 test/functional/users_controller_test.rb
@@ -0,0 +1,45 @@
+require 'test_helper'
+
+class UsersControllerTest < ActionController::TestCase
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:users)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create user" do
+ assert_difference('User.count') do
+ post :create, :user => { }
+ end
+
+ assert_redirected_to user_path(assigns(:user))
+ end
+
+ test "should show user" do
+ get :show, :id => users(:one).to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, :id => users(:one).to_param
+ assert_response :success
+ end
+
+ test "should update user" do
+ put :update, :id => users(:one).to_param, :user => { }
+ assert_redirected_to user_path(assigns(:user))
+ end
+
+ test "should destroy user" do
+ assert_difference('User.count', -1) do
+ delete :destroy, :id => users(:one).to_param
+ end
+
+ assert_redirected_to users_path
+ end
+end
View
4 test/unit/helpers/users_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class UsersHelperTest < ActionView::TestCase
+end
View
8 test/unit/user_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class UserTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end

0 comments on commit 090fe63

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