Permalink
Browse files

automatic import from ryanb/railscasts-episodes

  • Loading branch information...
ryanb committed Oct 10, 2011
0 parents commit b6edc83123674b963c0b83d662f474049cd8101b
Showing with 2,107 additions and 0 deletions.
  1. +7 −0 README
  2. +5 −0 saas-after/.gitignore
  3. +17 −0 saas-after/Gemfile
  4. +119 −0 saas-after/Gemfile.lock
  5. +7 −0 saas-after/README
  6. +7 −0 saas-after/Rakefile
  7. BIN saas-after/app/assets/images/llama.jpg
  8. BIN saas-after/app/assets/images/rails.png
  9. +9 −0 saas-after/app/assets/javascripts/application.js
  10. +3 −0 saas-after/app/assets/javascripts/plans.js.coffee
  11. +32 −0 saas-after/app/assets/javascripts/subscriptions.js.coffee
  12. +96 −0 saas-after/app/assets/stylesheets/application.css
  13. +82 −0 saas-after/app/assets/stylesheets/plans.css.scss
  14. +10 −0 saas-after/app/assets/stylesheets/subscriptions.css.scss
  15. +3 −0 saas-after/app/controllers/application_controller.rb
  16. +5 −0 saas-after/app/controllers/plans_controller.rb
  17. +19 −0 saas-after/app/controllers/subscriptions_controller.rb
  18. +2 −0 saas-after/app/helpers/application_helper.rb
  19. +2 −0 saas-after/app/helpers/plans_helper.rb
  20. +2 −0 saas-after/app/helpers/subscriptions_helper.rb
  21. 0 saas-after/app/mailers/.gitkeep
  22. 0 saas-after/app/models/.gitkeep
  23. +3 −0 saas-after/app/models/plan.rb
  24. +19 −0 saas-after/app/models/subscription.rb
  25. +18 −0 saas-after/app/views/layouts/application.html.erb
  26. +20 −0 saas-after/app/views/plans/index.html.erb
  27. +47 −0 saas-after/app/views/subscriptions/new.html.erb
  28. +4 −0 saas-after/app/views/subscriptions/show.html.erb
  29. +4 −0 saas-after/config.ru
  30. +48 −0 saas-after/config/application.rb
  31. +6 −0 saas-after/config/boot.rb
  32. +25 −0 saas-after/config/database.yml
  33. +5 −0 saas-after/config/environment.rb
  34. +30 −0 saas-after/config/environments/development.rb
  35. +60 −0 saas-after/config/environments/production.rb
  36. +39 −0 saas-after/config/environments/test.rb
  37. +7 −0 saas-after/config/initializers/backtrace_silencers.rb
  38. +10 −0 saas-after/config/initializers/inflections.rb
  39. +5 −0 saas-after/config/initializers/mime_types.rb
  40. +7 −0 saas-after/config/initializers/secret_token.rb
  41. +8 −0 saas-after/config/initializers/session_store.rb
  42. +2 −0 saas-after/config/initializers/stripe.rb
  43. +14 −0 saas-after/config/initializers/wrap_parameters.rb
  44. +5 −0 saas-after/config/locales/en.yml
  45. +5 −0 saas-after/config/routes.rb
  46. +11 −0 saas-after/db/migrate/20111008163507_create_plans.rb
  47. +10 −0 saas-after/db/migrate/20111008164003_create_subscriptions.rb
  48. +5 −0 saas-after/db/migrate/20111009193136_add_stripe_to_subscriptions.rb
  49. +32 −0 saas-after/db/schema.rb
  50. +4 −0 saas-after/db/seeds.rb
  51. +2 −0 saas-after/doc/README_FOR_APP
  52. 0 saas-after/lib/assets/.gitkeep
  53. 0 saas-after/lib/tasks/.gitkeep
  54. 0 saas-after/log/.gitkeep
  55. +26 −0 saas-after/public/404.html
  56. +26 −0 saas-after/public/422.html
  57. +26 −0 saas-after/public/500.html
  58. 0 saas-after/public/favicon.ico
  59. +5 −0 saas-after/public/robots.txt
  60. +6 −0 saas-after/script/rails
  61. 0 saas-after/test/fixtures/.gitkeep
  62. +11 −0 saas-after/test/fixtures/plans.yml
  63. +9 −0 saas-after/test/fixtures/subscriptions.yml
  64. 0 saas-after/test/functional/.gitkeep
  65. +9 −0 saas-after/test/functional/plans_controller_test.rb
  66. +49 −0 saas-after/test/functional/subscriptions_controller_test.rb
  67. 0 saas-after/test/integration/.gitkeep
  68. +12 −0 saas-after/test/performance/browsing_test.rb
  69. +13 −0 saas-after/test/test_helper.rb
  70. 0 saas-after/test/unit/.gitkeep
  71. +4 −0 saas-after/test/unit/helpers/plans_helper_test.rb
  72. +4 −0 saas-after/test/unit/helpers/subscriptions_helper_test.rb
  73. +7 −0 saas-after/test/unit/plan_test.rb
  74. +7 −0 saas-after/test/unit/subscription_test.rb
  75. 0 saas-after/vendor/assets/stylesheets/.gitkeep
  76. 0 saas-after/vendor/plugins/.gitkeep
  77. +5 −0 saas-before/.gitignore
  78. +15 −0 saas-before/Gemfile
  79. +117 −0 saas-before/Gemfile.lock
  80. +7 −0 saas-before/README
  81. +7 −0 saas-before/Rakefile
  82. BIN saas-before/app/assets/images/llama.jpg
  83. BIN saas-before/app/assets/images/rails.png
  84. +9 −0 saas-before/app/assets/javascripts/application.js
  85. +3 −0 saas-before/app/assets/javascripts/plans.js.coffee
  86. +3 −0 saas-before/app/assets/javascripts/subscriptions.js.coffee
  87. +96 −0 saas-before/app/assets/stylesheets/application.css
  88. +82 −0 saas-before/app/assets/stylesheets/plans.css.scss
  89. +10 −0 saas-before/app/assets/stylesheets/subscriptions.css.scss
  90. +3 −0 saas-before/app/controllers/application_controller.rb
  91. +5 −0 saas-before/app/controllers/plans_controller.rb
  92. +19 −0 saas-before/app/controllers/subscriptions_controller.rb
  93. +2 −0 saas-before/app/helpers/application_helper.rb
  94. +2 −0 saas-before/app/helpers/plans_helper.rb
  95. +2 −0 saas-before/app/helpers/subscriptions_helper.rb
  96. 0 saas-before/app/mailers/.gitkeep
  97. 0 saas-before/app/models/.gitkeep
  98. +3 −0 saas-before/app/models/plan.rb
  99. +5 −0 saas-before/app/models/subscription.rb
  100. +17 −0 saas-before/app/views/layouts/application.html.erb
  101. +20 −0 saas-before/app/views/plans/index.html.erb
  102. +25 −0 saas-before/app/views/subscriptions/new.html.erb
  103. +4 −0 saas-before/app/views/subscriptions/show.html.erb
  104. +4 −0 saas-before/config.ru
  105. +48 −0 saas-before/config/application.rb
  106. +6 −0 saas-before/config/boot.rb
  107. +25 −0 saas-before/config/database.yml
  108. +5 −0 saas-before/config/environment.rb
  109. +30 −0 saas-before/config/environments/development.rb
  110. +60 −0 saas-before/config/environments/production.rb
  111. +39 −0 saas-before/config/environments/test.rb
  112. +7 −0 saas-before/config/initializers/backtrace_silencers.rb
  113. +10 −0 saas-before/config/initializers/inflections.rb
  114. +5 −0 saas-before/config/initializers/mime_types.rb
  115. +7 −0 saas-before/config/initializers/secret_token.rb
  116. +8 −0 saas-before/config/initializers/session_store.rb
  117. +14 −0 saas-before/config/initializers/wrap_parameters.rb
  118. +5 −0 saas-before/config/locales/en.yml
  119. +5 −0 saas-before/config/routes.rb
  120. +11 −0 saas-before/db/migrate/20111008163507_create_plans.rb
  121. +10 −0 saas-before/db/migrate/20111008164003_create_subscriptions.rb
  122. +31 −0 saas-before/db/schema.rb
  123. +4 −0 saas-before/db/seeds.rb
  124. +2 −0 saas-before/doc/README_FOR_APP
  125. 0 saas-before/lib/assets/.gitkeep
  126. 0 saas-before/lib/tasks/.gitkeep
  127. 0 saas-before/log/.gitkeep
  128. +26 −0 saas-before/public/404.html
  129. +26 −0 saas-before/public/422.html
  130. +26 −0 saas-before/public/500.html
  131. 0 saas-before/public/favicon.ico
  132. +5 −0 saas-before/public/robots.txt
  133. +6 −0 saas-before/script/rails
  134. 0 saas-before/test/fixtures/.gitkeep
  135. +11 −0 saas-before/test/fixtures/plans.yml
  136. +9 −0 saas-before/test/fixtures/subscriptions.yml
  137. 0 saas-before/test/functional/.gitkeep
  138. +9 −0 saas-before/test/functional/plans_controller_test.rb
  139. +49 −0 saas-before/test/functional/subscriptions_controller_test.rb
  140. 0 saas-before/test/integration/.gitkeep
  141. +12 −0 saas-before/test/performance/browsing_test.rb
  142. +13 −0 saas-before/test/test_helper.rb
  143. 0 saas-before/test/unit/.gitkeep
  144. +4 −0 saas-before/test/unit/helpers/plans_helper_test.rb
  145. +4 −0 saas-before/test/unit/helpers/subscriptions_helper_test.rb
  146. +7 −0 saas-before/test/unit/plan_test.rb
  147. +7 −0 saas-before/test/unit/subscription_test.rb
  148. 0 saas-before/vendor/assets/stylesheets/.gitkeep
  149. 0 saas-before/vendor/plugins/.gitkeep
7 README
@@ -0,0 +1,7 @@
+RailsCasts Episode #288: Billing with Stripe
+
+http://railscasts.com/episodes/288-billing-with-stripe
+
+Commands used in episode
+
+ rails g migration add_stripe_to_subscriptions stripe_customer_token:string
@@ -0,0 +1,5 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/
+.sass-cache/
@@ -0,0 +1,17 @@
+source 'http://rubygems.org'
+
+gem 'rails', '3.1.1'
+gem 'rack', '1.3.3'
+gem 'sqlite3'
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', '~> 3.1.4'
+ gem 'coffee-rails', '~> 3.1.1'
+ gem 'uglifier', '>= 1.0.3'
+end
+
+gem 'jquery-rails'
+
+gem 'stripe'
@@ -0,0 +1,119 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ actionmailer (3.1.1)
+ actionpack (= 3.1.1)
+ mail (~> 2.3.0)
+ actionpack (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ i18n (~> 0.6)
+ rack (~> 1.3.2)
+ rack-cache (~> 1.1)
+ rack-mount (~> 0.8.2)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.0.2)
+ activemodel (3.1.1)
+ activesupport (= 3.1.1)
+ builder (~> 3.0.0)
+ i18n (~> 0.6)
+ activerecord (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ arel (~> 2.2.1)
+ tzinfo (~> 0.3.29)
+ activeresource (3.1.1)
+ activemodel (= 3.1.1)
+ activesupport (= 3.1.1)
+ activesupport (3.1.1)
+ multi_json (~> 1.0)
+ arel (2.2.1)
+ builder (3.0.0)
+ coffee-rails (3.1.1)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.1.0)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.1.2)
+ erubis (2.7.0)
+ execjs (1.2.9)
+ multi_json (~> 1.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ jquery-rails (1.0.14)
+ railties (~> 3.0)
+ thor (~> 0.14)
+ mail (2.3.0)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ multi_json (1.0.3)
+ polyglot (0.3.2)
+ rack (1.3.3)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-mount (0.8.3)
+ rack (>= 1.0.0)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.1.1)
+ actionmailer (= 3.1.1)
+ actionpack (= 3.1.1)
+ activerecord (= 3.1.1)
+ activeresource (= 3.1.1)
+ activesupport (= 3.1.1)
+ bundler (~> 1.0)
+ railties (= 3.1.1)
+ railties (3.1.1)
+ actionpack (= 3.1.1)
+ activesupport (= 3.1.1)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2)
+ rdoc (3.9.4)
+ rest-client (1.6.7)
+ mime-types (>= 1.16)
+ sass (3.1.10)
+ sass-rails (3.1.4)
+ actionpack (~> 3.1.0)
+ railties (~> 3.1.0)
+ sass (>= 3.1.4)
+ sprockets (~> 2.0.0)
+ tilt (~> 1.3.2)
+ sprockets (2.0.2)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.4)
+ stripe (1.5.20)
+ rest-client
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.30)
+ uglifier (1.0.3)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-rails (~> 3.1.1)
+ jquery-rails
+ rack (= 1.3.3)
+ rails (= 3.1.1)
+ sass-rails (~> 3.1.4)
+ sqlite3
+ stripe
+ uglifier (>= 1.0.3)
@@ -0,0 +1,7 @@
+= RailsCasts Example Application
+
+Run these commands to try it out.
+
+ bundle
+ rake db:setup
+ rails s
@@ -0,0 +1,7 @@
+#!/usr/bin/env rake
+# 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__)
+
+Saas::Application.load_tasks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,9 @@
+// This is a manifest file that'll be compiled into including all the files listed below.
+// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
+// be included in the compiled file accessible from http://example.com/assets/application.js
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
@@ -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/
@@ -0,0 +1,32 @@
+# 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/
+jQuery ->
+ Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content'))
+ subscription.setupForm()
+
+subscription =
+ setupForm: ->
+ $('#new_subscription').submit ->
+ $('input[type=submit]').attr('disabled', true)
+ if $('#card_number').length
+ subscription.processCard()
+ false
+ else
+ true
+
+ processCard: ->
+ card =
+ number: $('#card_number').val()
+ cvc: $('#card_code').val()
+ expMonth: $('#card_month').val()
+ expYear: $('#card_year').val()
+ Stripe.createToken(card, subscription.handleStripeResponse)
+
+ handleStripeResponse: (status, response) ->
+ if status == 200
+ $('#subscription_stripe_card_token').val(response.id)
+ $('#new_subscription')[0].submit()
+ else
+ $('#stripe_error').text(response.error.message)
+ $('input[type=submit]').attr('disabled', false)
@@ -0,0 +1,96 @@
+/*
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
+ *= require_self
+ *= require_tree .
+*/
+
+html, body {
+ background-color: #4B7399;
+ font-family: Verdana, Helvetica, Arial;
+ font-size: 14px;
+}
+
+a img {
+ border: none;
+}
+
+a {
+ color: #0000FF;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+.clear {
+ clear: both;
+ height: 0;
+ overflow: hidden;
+}
+
+#container {
+ width: 75%;
+ margin: 0 auto;
+ background-color: #FFF;
+ padding: 20px 40px;
+ border: solid 1px black;
+ margin-top: 20px;
+}
+
+#flash_notice, #flash_error, #flash_alert {
+ padding: 5px 8px;
+ margin: 10px 0;
+}
+
+#flash_notice {
+ background-color: #CFC;
+ border: solid 1px #6C6;
+}
+
+#flash_error, #flash_alert {
+ background-color: #FCC;
+ border: solid 1px #C66;
+}
+
+form label {
+ display: block;
+ margin-bottom: 2px;
+}
+
+form .field, form .actions {
+ margin: 12px 0;
+}
+
+.fieldWithErrors {
+ display: inline;
+}
+
+.error_messages {
+ width: 400px;
+ border: 2px solid #CF0000;
+ padding: 0px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+ font-size: 12px;
+}
+
+.error_messages h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 10px;
+ font-size: 12px;
+ margin: 0;
+ background-color: #c00;
+ color: #fff;
+}
+
+.error_messages p {
+ margin: 8px 10px;
+}
+
+.error_messages ul {
+ margin: 15px 0;
+}
@@ -0,0 +1,82 @@
+// Place all the styles related to the home controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
+#plans {
+ background-image: image-url("llama.jpg");
+ background-repeat: no-repeat;
+ background-position: 480px -10px;
+ margin: 0 auto;
+ padding-top: 60px;
+ margin-bottom: 10px;
+ width: 642px;
+ h1 {
+ font-size: 65px;
+ font-family: Georgia, Times;
+ margin-top: 0;
+ margin-bottom: 12px;
+ }
+ .plan {
+ float: left;
+ width: 150px;
+ text-align: center;
+ margin-right: 10px;
+ .name {
+ color: #FFF;
+ padding: 5px 0;
+ border: solid 1px #5B6881;
+ border-bottom: none;
+ background: #386FB2;
+ background: -webkit-gradient(linear, left top, left bottom, from(#67B0EF), to(#2B5EA4));
+ background: -moz-linear-gradient(top, #579CEA, #2B5EA4);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#579CEA', endColorstr='#2B5EA4');
+ border-top-left-radius: 5px;
+ border-top-right-radius: 5px;
+ -webkit-border-top-left-radius: 5px;
+ -webkit-border-top-right-radius: 5px;
+ -moz-border-radius-topleft: 5px;
+ -moz-border-radius-topright: 5px;
+ }
+ .details {
+ padding-top: 5px;
+ border: solid 1px #8D8D8D;
+ background-color: #E8F4FD;
+ border-top: none;
+ border-bottom-left-radius: 5px;
+ border-bottom-right-radius: 5px;
+ -webkit-border-bottom-left-radius: 5px;
+ -webkit-border-bottom-right-radius: 5px;
+ -moz-border-radius-bottomleft: 5px;
+ -moz-border-radius-bottomright: 5px;
+ }
+ .price {
+ font-size: 50px;
+ }
+ .per_month {
+ font-size: 12px;
+ margin-bottom: 10px;
+ color: #5E5E5E;
+ }
+ .kisses {
+ font-size: 18px;
+ }
+ .signup {
+ margin: 20px;
+ a {
+ font-size: 13px;
+ padding: 5px 10px 6px 10px;
+ font-weight: bold;
+ border: 1px solid #2A7531;
+ border-radius: 4px;
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ color: #FFF;
+ background: #328039;
+ background: -webkit-gradient(linear, left top, left bottom, from(#56D854), to(#328039));
+ background: -moz-linear-gradient(top, #56D854, #328039);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#56D854', endColorstr='#328039');
+ text-decoration: none;
+ text-shadow: 0 -1px 0 #036;
+ }
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit b6edc83

Please sign in to comment.