Permalink
Browse files

adding episode 216

  • Loading branch information...
1 parent 4e5bc1b commit 799cdf5b3a507a05fee50abef463eb231863338e @ryanb committed Jun 1, 2010
Showing with 9,513 additions and 0 deletions.
  1. +12 −0 episode-216/README
  2. +4 −0 episode-216/todo/.gitignore
  3. +33 −0 episode-216/todo/Gemfile
  4. +1 −0 episode-216/todo/README
  5. +10 −0 episode-216/todo/Rakefile
  6. +4 −0 episode-216/todo/app/controllers/application_controller.rb
  7. +83 −0 episode-216/todo/app/controllers/categories_controller.rb
  8. +83 −0 episode-216/todo/app/controllers/projects_controller.rb
  9. +83 −0 episode-216/todo/app/controllers/tasks_controller.rb
  10. +2 −0 episode-216/todo/app/helpers/application_helper.rb
  11. +2 −0 episode-216/todo/app/helpers/categories_helper.rb
  12. +2 −0 episode-216/todo/app/helpers/projects_helper.rb
  13. +2 −0 episode-216/todo/app/helpers/tasks_helper.rb
  14. +2 −0 episode-216/todo/app/models/category.rb
  15. +2 −0 episode-216/todo/app/models/foo.rb
  16. +2 −0 episode-216/todo/app/models/project.rb
  17. +2 −0 episode-216/todo/app/models/task.rb
  18. +20 −0 episode-216/todo/app/views/categories/_form.html.erb
  19. +6 −0 episode-216/todo/app/views/categories/edit.html.erb
  20. +23 −0 episode-216/todo/app/views/categories/index.html.erb
  21. +5 −0 episode-216/todo/app/views/categories/new.html.erb
  22. +10 −0 episode-216/todo/app/views/categories/show.html.erb
  23. +14 −0 episode-216/todo/app/views/layouts/application.html.erb
  24. +20 −0 episode-216/todo/app/views/projects/_form.html.erb
  25. +6 −0 episode-216/todo/app/views/projects/edit.html.erb
  26. +21 −0 episode-216/todo/app/views/projects/index.html.erb
  27. +5 −0 episode-216/todo/app/views/projects/new.html.erb
  28. +10 −0 episode-216/todo/app/views/projects/show.html.erb
  29. +24 −0 episode-216/todo/app/views/tasks/_form.html.erb
  30. +6 −0 episode-216/todo/app/views/tasks/edit.html.erb
  31. +25 −0 episode-216/todo/app/views/tasks/index.html.erb
  32. +5 −0 episode-216/todo/app/views/tasks/new.html.erb
  33. +15 −0 episode-216/todo/app/views/tasks/show.html.erb
  34. +4 −0 episode-216/todo/config.ru
  35. +49 −0 episode-216/todo/config/application.rb
  36. +6 −0 episode-216/todo/config/boot.rb
  37. +22 −0 episode-216/todo/config/database.yml
  38. +5 −0 episode-216/todo/config/environment.rb
  39. +19 −0 episode-216/todo/config/environments/development.rb
  40. +42 −0 episode-216/todo/config/environments/production.rb
  41. +32 −0 episode-216/todo/config/environments/test.rb
  42. +7 −0 episode-216/todo/config/initializers/backtrace_silencers.rb
  43. +10 −0 episode-216/todo/config/initializers/inflections.rb
  44. +5 −0 episode-216/todo/config/initializers/mime_types.rb
  45. +7 −0 episode-216/todo/config/initializers/secret_token.rb
  46. +8 −0 episode-216/todo/config/initializers/session_store.rb
  47. +5 −0 episode-216/todo/config/locales/en.yml
  48. +64 −0 episode-216/todo/config/routes.rb
  49. +13 −0 episode-216/todo/db/migrate/20100531193853_create_projects.rb
  50. +14 −0 episode-216/todo/db/migrate/20100531213956_create_tasks.rb
  51. +13 −0 episode-216/todo/db/migrate/20100531220055_create_categories.rb
  52. +7 −0 episode-216/todo/db/seeds.rb
  53. +2 −0 episode-216/todo/doc/README_FOR_APP
  54. 0 episode-216/todo/lib/tasks/.gitkeep
  55. +25 −0 episode-216/todo/lib/templates/erb/scaffold/index.html.erb
  56. +26 −0 episode-216/todo/public/404.html
  57. +26 −0 episode-216/todo/public/422.html
  58. +26 −0 episode-216/todo/public/500.html
  59. 0 episode-216/todo/public/favicon.ico
  60. BIN episode-216/todo/public/images/rails.png
  61. +279 −0 episode-216/todo/public/index.html
  62. +2 −0 episode-216/todo/public/javascripts/application.js
  63. +965 −0 episode-216/todo/public/javascripts/controls.js
  64. +974 −0 episode-216/todo/public/javascripts/dragdrop.js
  65. +1,123 −0 episode-216/todo/public/javascripts/effects.js
  66. +4,874 −0 episode-216/todo/public/javascripts/prototype.js
  67. +118 −0 episode-216/todo/public/javascripts/rails.js
  68. +5 −0 episode-216/todo/public/robots.txt
  69. 0 episode-216/todo/public/stylesheets/.gitkeep
  70. +9 −0 episode-216/todo/script/rails
  71. +5 −0 episode-216/todo/test/factories/categories.rb
  72. +6 −0 episode-216/todo/test/factories/tasks.rb
  73. +7 −0 episode-216/todo/test/fixtures/foos.yml
  74. +7 −0 episode-216/todo/test/fixtures/projects.yml
  75. +49 −0 episode-216/todo/test/functional/categories_controller_test.rb
  76. +49 −0 episode-216/todo/test/functional/projects_controller_test.rb
  77. +9 −0 episode-216/todo/test/performance/browsing_test.rb
  78. +13 −0 episode-216/todo/test/test_helper.rb
  79. +7 −0 episode-216/todo/test/unit/category_test.rb
  80. +8 −0 episode-216/todo/test/unit/foo_test.rb
  81. +4 −0 episode-216/todo/test/unit/helpers/categories_helper_test.rb
  82. +4 −0 episode-216/todo/test/unit/helpers/projects_helper_test.rb
  83. +8 −0 episode-216/todo/test/unit/project_test.rb
  84. +7 −0 episode-216/todo/test/unit/task_test.rb
  85. 0 episode-216/todo/vendor/plugins/.gitkeep
View
@@ -0,0 +1,12 @@
+Railscasts Episode #216: Generators in Rails 3
+
+http://railscasts.com/episodes/216
+
+Commands
+
+ rails g
+ rails g scaffold --help
+ rails g scaffold project name:string --no-stylesheets
+ bundle install
+ rails g scaffold task project_id:integer
+ rails g scaffold category name:string
@@ -0,0 +1,4 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/**/*
View
@@ -0,0 +1,33 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.0.0.beta3'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3-ruby', :require => 'sqlite3'
+
+group :test do
+ gem "shoulda"
+ gem "factory_girl"
+end
+
+gem "rails3-generators", :group => :development
+
+# Use unicorn as the web server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# Bundle the extra gems:
+# gem 'bj'
+# gem 'nokogiri', '1.4.1'
+# gem 'sqlite3-ruby', :require => 'sqlite3'
+# gem 'aws-s3', :require => 'aws/s3'
+
+# Bundle gems for certain environments:
+# gem 'rspec', :group => :test
+# group :test do
+# gem 'webrat'
+# end
View
@@ -0,0 +1 @@
+Railscasts example application.
View
@@ -0,0 +1,10 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+Rails::Application.load_tasks
@@ -0,0 +1,4 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+ layout 'application'
+end
@@ -0,0 +1,83 @@
+class CategoriesController < ApplicationController
+ # GET /categories
+ # GET /categories.xml
+ def index
+ @categories = Category.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @categories }
+ end
+ end
+
+ # GET /categories/1
+ # GET /categories/1.xml
+ def show
+ @category = Category.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @category }
+ end
+ end
+
+ # GET /categories/new
+ # GET /categories/new.xml
+ def new
+ @category = Category.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @category }
+ end
+ end
+
+ # GET /categories/1/edit
+ def edit
+ @category = Category.find(params[:id])
+ end
+
+ # POST /categories
+ # POST /categories.xml
+ def create
+ @category = Category.new(params[:category])
+
+ respond_to do |format|
+ if @category.save
+ format.html { redirect_to(@category, :notice => 'Category was successfully created.') }
+ format.xml { render :xml => @category, :status => :created, :location => @category }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /categories/1
+ # PUT /categories/1.xml
+ def update
+ @category = Category.find(params[:id])
+
+ respond_to do |format|
+ if @category.update_attributes(params[:category])
+ format.html { redirect_to(@category, :notice => 'Category was successfully updated.') }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /categories/1
+ # DELETE /categories/1.xml
+ def destroy
+ @category = Category.find(params[:id])
+ @category.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(categories_url) }
+ format.xml { head :ok }
+ end
+ end
+end
@@ -0,0 +1,83 @@
+class ProjectsController < ApplicationController
+ # GET /projects
+ # GET /projects.xml
+ def index
+ @projects = Project.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @projects }
+ end
+ end
+
+ # GET /projects/1
+ # GET /projects/1.xml
+ def show
+ @project = Project.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @project }
+ end
+ end
+
+ # GET /projects/new
+ # GET /projects/new.xml
+ def new
+ @project = Project.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @project }
+ end
+ end
+
+ # GET /projects/1/edit
+ def edit
+ @project = Project.find(params[:id])
+ end
+
+ # POST /projects
+ # POST /projects.xml
+ def create
+ @project = Project.new(params[:project])
+
+ respond_to do |format|
+ if @project.save
+ format.html { redirect_to(@project, :notice => 'Project was successfully created.') }
+ format.xml { render :xml => @project, :status => :created, :location => @project }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /projects/1
+ # PUT /projects/1.xml
+ def update
+ @project = Project.find(params[:id])
+
+ respond_to do |format|
+ if @project.update_attributes(params[:project])
+ format.html { redirect_to(@project, :notice => 'Project was successfully updated.') }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @project.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /projects/1
+ # DELETE /projects/1.xml
+ def destroy
+ @project = Project.find(params[:id])
+ @project.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(projects_url) }
+ format.xml { head :ok }
+ end
+ end
+end
@@ -0,0 +1,83 @@
+class TasksController < ApplicationController
+ # GET /tasks
+ # GET /tasks.xml
+ def index
+ @tasks = Task.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @tasks }
+ end
+ end
+
+ # GET /tasks/1
+ # GET /tasks/1.xml
+ def show
+ @task = Task.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @task }
+ end
+ end
+
+ # GET /tasks/new
+ # GET /tasks/new.xml
+ def new
+ @task = Task.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @task }
+ end
+ end
+
+ # GET /tasks/1/edit
+ def edit
+ @task = Task.find(params[:id])
+ end
+
+ # POST /tasks
+ # POST /tasks.xml
+ def create
+ @task = Task.new(params[:task])
+
+ respond_to do |format|
+ if @task.save
+ format.html { redirect_to(@task, :notice => 'Task was successfully created.') }
+ format.xml { render :xml => @task, :status => :created, :location => @task }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @task.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /tasks/1
+ # PUT /tasks/1.xml
+ def update
+ @task = Task.find(params[:id])
+
+ respond_to do |format|
+ if @task.update_attributes(params[:task])
+ format.html { redirect_to(@task, :notice => 'Task was successfully updated.') }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @task.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /tasks/1
+ # DELETE /tasks/1.xml
+ def destroy
+ @task = Task.find(params[:id])
+ @task.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(tasks_url) }
+ format.xml { head :ok }
+ end
+ end
+end
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
@@ -0,0 +1,2 @@
+module CategoriesHelper
+end
@@ -0,0 +1,2 @@
+module ProjectsHelper
+end
@@ -0,0 +1,2 @@
+module TasksHelper
+end
@@ -0,0 +1,2 @@
+class Category < ActiveRecord::Base
+end
@@ -0,0 +1,2 @@
+class Foo < ActiveRecord::Base
+end
@@ -0,0 +1,2 @@
+class Project < ActiveRecord::Base
+end
@@ -0,0 +1,2 @@
+class Task < ActiveRecord::Base
+end
@@ -0,0 +1,20 @@
+<%= form_for(@category) do |f| %>
+ <% if @category.errors.any? %>
+ <div id="errorExplanation">
+ <h2><%= pluralize(@category.errors.count, "error") %> prohibited this category from being saved:</h2>
+ <ul>
+ <% @category.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div class="field">
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </div>
+ <div class="actions">
+ <%= f.submit %>
+ </div>
+<% end %>
@@ -0,0 +1,6 @@
+<h1>Editing category</h1>
+
+<%= render 'form' %>
+
+<%= link_to 'Show', @category %> |
+<%= link_to 'Back', categories_path %>
@@ -0,0 +1,23 @@
+<h1>Listing categories</h1>
+
+<table>
+ <tr>
+ <th>Name</th>
+ <th></th>
+ <th></th>
+ <th></th>
+ </tr>
+
+<% @categories.each do |category| %>
+ <tr>
+ <td><%= category.name %></td>
+ <td><%= link_to 'Show', category %></td>
+ <td><%= link_to 'Edit', edit_category_path(category) %></td>
+ <td><%= link_to 'Destroy', category, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New Category', new_category_path %>
Oops, something went wrong.

0 comments on commit 799cdf5

Please sign in to comment.