Permalink
Browse files

adding episode 116

  • Loading branch information...
1 parent 540954a commit 3f052e713adc3814792b56647d750c9c4ba3a275 @ryanb committed Jun 30, 2008
Showing with 37,194 additions and 0 deletions.
  1. +10 −0 episode-116/README
  2. +3 −0 episode-116/store/.gitignore
  3. +4 −0 episode-116/store/README
  4. +10 −0 episode-116/store/Rakefile
  5. +15 −0 episode-116/store/app/controllers/application.rb
  6. +44 −0 episode-116/store/app/controllers/categories_controller.rb
  7. +47 −0 episode-116/store/app/controllers/products_controller.rb
  8. +3 −0 episode-116/store/app/helpers/application_helper.rb
  9. +2 −0 episode-116/store/app/helpers/categories_helper.rb
  10. +23 −0 episode-116/store/app/helpers/layout_helper.rb
  11. +2 −0 episode-116/store/app/helpers/products_helper.rb
  12. +3 −0 episode-116/store/app/models/category.rb
  13. +3 −0 episode-116/store/app/models/product.rb
  14. +7 −0 episode-116/store/app/views/categories/_form.html.erb
  15. +8 −0 episode-116/store/app/views/categories/edit.html.erb
  16. +13 −0 episode-116/store/app/views/categories/index.html.erb
  17. +5 −0 episode-116/store/app/views/categories/new.html.erb
  18. +13 −0 episode-116/store/app/views/categories/show.html.erb
  19. +23 −0 episode-116/store/app/views/layouts/application.html.erb
  20. +19 −0 episode-116/store/app/views/products/_form.html.erb
  21. +3 −0 episode-116/store/app/views/products/destroy.js.rjs
  22. +8 −0 episode-116/store/app/views/products/edit.html.erb
  23. +16 −0 episode-116/store/app/views/products/index.html.erb
  24. +5 −0 episode-116/store/app/views/products/new.html.erb
  25. +21 −0 episode-116/store/app/views/products/show.html.erb
  26. +109 −0 episode-116/store/config/boot.rb
  27. +19 −0 episode-116/store/config/database.yml
  28. +67 −0 episode-116/store/config/environment.rb
  29. +17 −0 episode-116/store/config/environments/development.rb
  30. +22 −0 episode-116/store/config/environments/production.rb
  31. +22 −0 episode-116/store/config/environments/test.rb
  32. +10 −0 episode-116/store/config/initializers/inflections.rb
  33. +5 −0 episode-116/store/config/initializers/mime_types.rb
  34. +15 −0 episode-116/store/config/initializers/new_rails_defaults.rb
  35. +5 −0 episode-116/store/config/routes.rb
  36. +33 −0 episode-116/store/config/selenium.yml
  37. +12 −0 episode-116/store/db/migrate/20080621194238_create_categories.rb
  38. +15 −0 episode-116/store/db/migrate/20080621194423_create_products.rb
  39. +29 −0 episode-116/store/db/schema.rb
  40. +22 −0 episode-116/store/lib/tasks/application.rake
  41. +30 −0 episode-116/store/public/404.html
  42. +30 −0 episode-116/store/public/422.html
  43. +30 −0 episode-116/store/public/500.html
  44. +10 −0 episode-116/store/public/dispatch.cgi
  45. +24 −0 episode-116/store/public/dispatch.fcgi
  46. +10 −0 episode-116/store/public/dispatch.rb
  47. 0 episode-116/store/public/favicon.ico
  48. +2 −0 episode-116/store/public/javascripts/application.js
  49. +963 −0 episode-116/store/public/javascripts/controls.js
  50. +972 −0 episode-116/store/public/javascripts/dragdrop.js
  51. +1,120 −0 episode-116/store/public/javascripts/effects.js
  52. +4,225 −0 episode-116/store/public/javascripts/prototype.js
  53. +5 −0 episode-116/store/public/robots.txt
  54. +88 −0 episode-116/store/public/stylesheets/application.css
  55. +3 −0 episode-116/store/script/about
  56. +3 −0 episode-116/store/script/console
  57. +3 −0 episode-116/store/script/dbconsole
  58. +3 −0 episode-116/store/script/destroy
  59. +3 −0 episode-116/store/script/generate
  60. +3 −0 episode-116/store/script/performance/benchmarker
  61. +3 −0 episode-116/store/script/performance/profiler
  62. +3 −0 episode-116/store/script/performance/request
  63. +3 −0 episode-116/store/script/plugin
  64. +3 −0 episode-116/store/script/process/inspector
  65. +3 −0 episode-116/store/script/process/reaper
  66. +3 −0 episode-116/store/script/process/spawner
  67. +3 −0 episode-116/store/script/runner
  68. +3 −0 episode-116/store/script/server
  69. +5 −0 episode-116/store/test/fixtures/categories.yml
  70. +9 −0 episode-116/store/test/fixtures/products.yml
  71. +54 −0 episode-116/store/test/functional/categories_controller_test.rb
  72. +54 −0 episode-116/store/test/functional/products_controller_test.rb
  73. +9 −0 episode-116/store/test/selenium/destroy_product.rsel
  74. +38 −0 episode-116/store/test/test_helper.rb
  75. +8 −0 episode-116/store/test/unit/category_test.rb
  76. +8 −0 episode-116/store/test/unit/product_test.rb
  77. 0 episode-116/store/vendor/plugins/.gitignore
  78. +1 −0 episode-116/store/vendor/plugins/selenium-on-rails/.gitignore
  79. +125 −0 episode-116/store/vendor/plugins/selenium-on-rails/CHANGELOG
  80. +202 −0 episode-116/store/vendor/plugins/selenium-on-rails/LICENSE-2.0.txt
  81. +193 −0 episode-116/store/vendor/plugins/selenium-on-rails/README
  82. +27 −0 episode-116/store/vendor/plugins/selenium-on-rails/Rakefile
  83. +33 −0 episode-116/store/vendor/plugins/selenium-on-rails/config.yml.example
  84. +19 −0 episode-116/store/vendor/plugins/selenium-on-rails/generators/selenium/USAGE
  85. +50 −0 episode-116/store/vendor/plugins/selenium-on-rails/generators/selenium/selenium_generator.rb
  86. +16 −0 episode-116/store/vendor/plugins/selenium-on-rails/generators/selenium/templates/rhtml.rhtml
  87. +14 −0 episode-116/store/vendor/plugins/selenium-on-rails/generators/selenium/templates/rselenese.rhtml
  88. +11 −0 episode-116/store/vendor/plugins/selenium-on-rails/generators/selenium/templates/selenese.rhtml
  89. +20 −0 episode-116/store/vendor/plugins/selenium-on-rails/init.rb
  90. +119 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/controllers/selenium_controller.rb
  91. +9 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_helper.rb
  92. +11 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails.rb
  93. +213 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/acceptance_test_runner.rb
  94. +56 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/fixture_loader.rb
  95. +38 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/partials_support.rb
  96. +55 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/paths.rb
  97. +17 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/renderer.rb
  98. +39 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/rselenese.rb
  99. +86 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/selenese.rb
  100. +51 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/suite_renderer.rb
  101. +113 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder.rb
  102. +1,002 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_accessors.rb
  103. +515 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_actions.rb
  104. +91 −0 ...ore/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_user_accessors.rb.example
  105. +24 −0 ...store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails/test_builder_user_actions.rb.example
  106. +25 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/selenium_on_rails_config.rb
  107. +18 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/views/layout.rhtml
  108. +5 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/views/record.rhtml
  109. +67 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/views/setup.rhtml
  110. +26 −0 episode-116/store/vendor/plugins/selenium-on-rails/lib/views/test_suite.rhtml
  111. +23 −0 episode-116/store/vendor/plugins/selenium-on-rails/routes.rb
  112. +8 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/Blank.html
  113. +8 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/InjectedRemoteRunner.html
  114. +109 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/RemoteRunner.html
  115. +74 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/SeleniumLog.html
  116. +123 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/TestPrompt.html
  117. +55 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/TestRunner-splash.html
  118. +175 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/TestRunner.hta
  119. +175 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/TestRunner.html
  120. BIN episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/domviewer/butmin.gif
  121. BIN episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/domviewer/butplus.gif
  122. +298 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/domviewer/domviewer.css
  123. +16 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/domviewer/domviewer.html
  124. +205 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/domviewer/selenium-domviewer.js
  125. BIN episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/icons/all.png
  126. BIN episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/icons/continue.png
  127. BIN episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/icons/continue_disabled.png
  128. BIN episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/icons/pause.png
  129. BIN episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/icons/pause_disabled.png
  130. BIN episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/icons/selected.png
  131. BIN episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/icons/step.png
  132. BIN episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/icons/step_disabled.png
  133. +1,431 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/iedoc-core.xml
  134. +1,368 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/iedoc.xml
  135. +6 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/cssQuery/cssQuery-p.js
  136. +142 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/cssQuery/src/cssQuery-level2.js
  137. +150 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/cssQuery/src/cssQuery-level3.js
  138. +53 −0 ...de-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/cssQuery/src/cssQuery-standard.js
  139. +356 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/cssQuery/src/cssQuery.js
  140. +2,006 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/prototype.js
  141. +101 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/builder.js
  142. +815 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/controls.js
  143. +915 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/dragdrop.js
  144. +958 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/effects.js
  145. +47 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/scriptaculous.js
  146. +283 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/slider.js
  147. +383 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/lib/scriptaculous/unittest.js
  148. +69 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/find_matching_child.js
  149. +842 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/htmlutils.js
  150. +79 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/injection.html
  151. +7 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/injection_iframe.html
  152. +70 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/js2html.js
  153. +175 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/narcissus-defs.js
  154. +1,054 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/narcissus-exec.js
  155. +1,003 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/narcissus-parse.js
  156. +63 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/se2html.js
  157. +2,329 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-api.js
  158. +1,946 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-browserbot.js
  159. +142 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-browserdetect.js
  160. +375 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-commandhandlers.js
  161. +177 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-executionloop.js
  162. +139 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-logging.js
  163. +466 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-remoterunner.js
  164. +1,281 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-testrunner.js
  165. +5 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/selenium-version.js
  166. +75 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/user-extensions.js.sample
  167. +153 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/scripts/xmlextras.js
  168. BIN episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/selenium-logo.png
  169. +43 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/selenium-test.css
  170. +299 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/selenium.css
  171. +428 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/xpath/dom.js
  172. +255 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/xpath/misc.js
  173. +2,182 −0 episode-116/store/vendor/plugins/selenium-on-rails/selenium-core/xpath/xpath.js
  174. +20 −0 episode-116/store/vendor/plugins/selenium-on-rails/switch_environment/init.rb
  175. +16 −0 ...de-116/store/vendor/plugins/selenium-on-rails/switch_environment/switch_environment_controller.rb
  176. +8 −0 episode-116/store/vendor/plugins/selenium-on-rails/tasks/test_acceptance.rake
  177. +147 −0 episode-116/store/vendor/plugins/selenium-on-rails/test/renderer_test.rb
  178. +672 −0 episode-116/store/vendor/plugins/selenium-on-rails/test/rselenese_test.rb
  179. +229 −0 episode-116/store/vendor/plugins/selenium-on-rails/test/selenese_test.rb
  180. +48 −0 episode-116/store/vendor/plugins/selenium-on-rails/test/selenium_controller_test.rb
  181. +33 −0 episode-116/store/vendor/plugins/selenium-on-rails/test/selenium_support_test.rb
  182. +29 −0 episode-116/store/vendor/plugins/selenium-on-rails/test/setup_test.rb
  183. +173 −0 episode-116/store/vendor/plugins/selenium-on-rails/test/suite_renderer_test.rb
  184. +70 −0 episode-116/store/vendor/plugins/selenium-on-rails/test/test_helper.rb
  185. 0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/.hidden.html
  186. +1 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/_partial.rsel
  187. +6 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/html.html
  188. +12 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/own_layout.html
  189. +6 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/partials/_html.html
  190. +2 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/partials/_nesting.rsel
  191. +6 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/partials/_rhtml.rhtml
  192. +1 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/partials/_rsel.rsel
  193. +5 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/partials/_sel.sel
  194. +5 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/partials/all_partials.rsel
  195. +7 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/rhtml.rhtml
  196. +8 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/rselenese.rsel
  197. +7 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/selenese.sel
  198. +1 −0 ...ore/vendor/plugins/selenium-on-rails/test_data/suite_one/subsuite/suite_one_subsuite_testcase.sel
  199. +1 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/suite_one/suite_one_testcase1.sel
  200. +1 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/suite_one/suite_one_testcase2.sel
  201. +1 −0 episode-116/store/vendor/plugins/selenium-on-rails/test_data/suite_two/suite_two_testcase.sel
View
@@ -0,0 +1,10 @@
+Railscasts Episode #116: Selenium
+
+http://railscasts.com/episodes/116
+
+Outline
+- start server in test env
+- show testing product creation with Selenium IDE
+- install selenium on rails plugin
+- generate selenium test case for destroy action
+- fix confirmation bug
@@ -0,0 +1,3 @@
+tmp/*
+log/*
+*.sqlite3
View
@@ -0,0 +1,4 @@
+Railscasts Example Store App
+--
+
+To setup the app, just run `rake setup`.
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.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'
@@ -0,0 +1,15 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ helper :all # include all helpers, all the time
+
+ # See ActionController::RequestForgeryProtection for details
+ # Uncomment the :secret if you're not using the cookie session store
+ protect_from_forgery # :secret => '526292d4095d0fd8135a9aa118f5956e'
+
+ # See ActionController::Base for details
+ # Uncomment this to filter the contents of submitted sensitive data parameters
+ # from your application log (in this case, all fields with names like "password").
+ # filter_parameter_logging :password
+end
@@ -0,0 +1,44 @@
+class CategoriesController < ApplicationController
+ def index
+ @categories = Category.find(:all)
+ end
+
+ def show
+ @category = Category.find(params[:id])
+ end
+
+ def new
+ @category = Category.new
+ end
+
+ def create
+ @category = Category.new(params[:category])
+ if @category.save
+ flash[:notice] = "Successfully created category."
+ redirect_to @category
+ else
+ render :action => 'new'
+ end
+ end
+
+ def edit
+ @category = Category.find(params[:id])
+ end
+
+ def update
+ @category = Category.find(params[:id])
+ if @category.update_attributes(params[:category])
+ flash[:notice] = "Successfully updated category."
+ redirect_to @category
+ else
+ render :action => 'edit'
+ end
+ end
+
+ def destroy
+ @category = Category.find(params[:id])
+ @category.destroy
+ flash[:notice] = "Successfully destroyed category."
+ redirect_to categories_url
+ end
+end
@@ -0,0 +1,47 @@
+class ProductsController < ApplicationController
+ def index
+ @products = Product.all(:limit => 10)
+ end
+
+ def show
+ @product = Product.find(params[:id])
+ end
+
+ def new
+ @product = Product.new
+ end
+
+ def create
+ @product = Product.new(params[:product])
+ if @product.save
+ flash[:notice] = "Successfully created product."
+ redirect_to @product
+ else
+ render :action => 'new'
+ end
+ end
+
+ def edit
+ @product = Product.find(params[:id])
+ end
+
+ def update
+ @product = Product.find(params[:id])
+ if @product.update_attributes(params[:product])
+ flash[:notice] = "Successfully updated product."
+ redirect_to @product
+ else
+ render :action => 'edit'
+ end
+ end
+
+ def destroy
+ @product = Product.find(params[:id])
+ @product.destroy
+ flash[:notice] = "Successfully destroyed product."
+ respond_to do |format|
+ format.html { redirect_to(products_url) }
+ format.js
+ end
+ end
+end
@@ -0,0 +1,3 @@
+# Methods added to this helper will be available to all templates in the application.
+module ApplicationHelper
+end
@@ -0,0 +1,2 @@
+module CategoriesHelper
+end
@@ -0,0 +1,23 @@
+# These helper methods can be called in your template to set variables to be used in the layout
+# This module should be included in all views globally,
+# to do so you may need to add this line to your ApplicationController
+# helper :layout
+module LayoutHelper
+ def title(page_title, show_title = true)
+ @content_for_title = page_title.to_s
+ @show_title = show_title
+ end
+
+ def show_title?
+ @show_title
+ end
+
+ def stylesheet(*args)
+ content_for(:head) { stylesheet_link_tag(*args.map(&:to_s)) }
+ end
+
+ def javascript(*args)
+ args = args.map { |arg| arg == :defaults ? arg : arg.to_s }
+ content_for(:head) { javascript_include_tag(*args) }
+ end
+end
@@ -0,0 +1,2 @@
+module ProductsHelper
+end
@@ -0,0 +1,3 @@
+class Category < ActiveRecord::Base
+ has_many :products
+end
@@ -0,0 +1,3 @@
+class Product < ActiveRecord::Base
+ belongs_to :category
+end
@@ -0,0 +1,7 @@
+<% form_for @category do |f| %>
+ <p>
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </p>
+ <p><%= f.submit "Submit" %></p>
+<% end %>
@@ -0,0 +1,8 @@
+<% title "Edit Category" %>
+
+<%= render :partial => 'form' %>
+
+<p>
+ <%= link_to "Show", @category %> |
+ <%= link_to "View All", categories_path %>
+</p>
@@ -0,0 +1,13 @@
+<% title "Categories" %>
+
+<% for category in @categories %>
+ <div class="category">
+ <h3><%= link_to h(category.name), category %></h3>
+ <div class="actions">
+ <%= link_to "Edit", edit_category_path(category) %> |
+ <%= link_to "Destroy", category, :confirm => 'Are you sure?', :method => :delete %>
+ </div>
+ </div>
+<% end %>
+
+<p><%= link_to "New Category", new_category_path %></p>
@@ -0,0 +1,5 @@
+<% title "New Category" %>
+
+<%= render :partial => 'form' %>
+
+<p><%= link_to "Back to List", categories_path %></p>
@@ -0,0 +1,13 @@
+<% title @category.name %>
+
+<ul>
+<% for product in @category.products %>
+ <li><%= link_to h(product.name), product %></li>
+<% end %>
+</ul>
+
+<p>
+ <%= link_to "Edit", edit_category_path(@category) %> |
+ <%= link_to "Destroy", @category, :confirm => 'Are you sure?', :method => :delete %> |
+ <%= link_to "View All", categories_path %>
+</p>
@@ -0,0 +1,23 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+ <head>
+ <title><%= h(yield(:title) || "Untitled") %></title>
+ <%= stylesheet_link_tag 'application' %>
+ <%= javascript_include_tag :defaults %>
+ <%= yield(:head) %>
+ </head>
+ <body>
+ <div id="container">
+ <%- flash.each do |name, msg| -%>
+ <%= content_tag :div, msg, :id => "flash_#{name}" %>
+ <%- end -%>
+
+ <%- if show_title? -%>
+ <h1><%=h yield(:title) %></h1>
+ <%- end -%>
+
+ <%= yield %>
+ </div>
+ </body>
+</html>
@@ -0,0 +1,19 @@
+<% form_for @product do |f| %>
+ <p>
+ <%= f.label :category_id %><br />
+ <%= f.collection_select :category_id, Category.all, :id, :name %>
+ </p>
+ <p>
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </p>
+ <p>
+ <%= f.label :price %><br />
+ <%= f.text_field :price %>
+ </p>
+ <p>
+ <%= f.label :description %><br />
+ <%= f.text_area :description %>
+ </p>
+ <p><%= f.submit "Submit" %></p>
+<% end %>
@@ -0,0 +1,3 @@
+page[@product].remove
+page.insert_html :top, :container, content_tag(:div, flash[:notice], :id => 'flash_notice')
+flash.discard
@@ -0,0 +1,8 @@
+<% title "Edit Product" %>
+
+<%= render :partial => 'form' %>
+
+<p>
+ <%= link_to "Show", @product %> |
+ <%= link_to "View All", products_path %>
+</p>
@@ -0,0 +1,16 @@
+<% title "Products" %>
+
+<% for product in @products %>
+ <% div_for product do %>
+ <h3>
+ <%= link_to h(product.name), product %>
+ <%= number_to_currency(product.price) %>
+ </h3>
+ <div class="actions">
+ <%= link_to "Edit", edit_product_path(product) %> |
+ <%= link_to_remote "Destroy", :url => product, :method => :delete, :confirm => 'Are you sure?' %>
+ </div>
+ <% end %>
+<% end %>
+
+<p><%= link_to "New Product", new_product_path %></p>
@@ -0,0 +1,5 @@
+<% title "New Product" %>
+
+<%= render :partial => 'form' %>
+
+<p><%= link_to "Back to List", products_path %></p>
@@ -0,0 +1,21 @@
+<% title @product.name %>
+
+<%= simple_format h(@product.description) %>
+
+<p>
+ <strong>Price:</strong>
+ <%= number_to_currency @product.price %>
+</p>
+
+<% unless @product.category.nil? %>
+<p>
+ <strong>Category:</strong>
+ <%= link_to h(@product.category.name), @product.category %>
+</p>
+<% end %>
+
+<p>
+ <%= link_to "Edit", edit_product_path(@product) %> |
+ <%= link_to "Destroy", @product, :confirm => 'Are you sure?', :method => :delete %> |
+ <%= link_to "View All", products_path %>
+</p>
Oops, something went wrong.

0 comments on commit 3f052e7

Please sign in to comment.