Skip to content
This repository
Browse code

upgrading to Rails 3

  • Loading branch information...
commit 5f58f79ba929eb548058bb15d318315436263036 1 parent b6bb9e2
Ryan Bates authored

Showing 113 changed files with 7,816 additions and 9,179 deletions. Show diff stats Hide diff stats

  1. +6 4 .gitignore
  2. +1 0  .rspec
  3. +24 0 Gemfile
  4. +129 0 Gemfile.lock
  5. +2 2 LICENSE
  6. +2 10 Rakefile
  7. +0 15 TODO
  8. +1 10 app/controllers/application_controller.rb
  9. +1 2  app/helpers/application_helper.rb
  10. +23 0 app/helpers/error_messages_helper.rb
  11. +5 6 app/helpers/layout_helper.rb
  12. +1 1  app/models/comment.rb
  13. +3 3 app/models/episode.rb
  14. +1 1  app/models/spam_question.rb
  15. +3 3 app/models/spam_report.rb
  16. +1 1  app/models/sponsor.rb
  17. +3 3 app/views/comments/_comment.html.erb
  18. +4 4 app/views/comments/_form.html.erb
  19. +1 1  app/views/comments/index.html.erb
  20. +3 3 app/views/episodes/_episode.html.erb
  21. +5 5 app/views/episodes/_form.html.erb
  22. +2 2 app/views/episodes/archive.html.erb
  23. +3 3 app/views/episodes/index.html.erb
  24. +4 4 app/views/episodes/show.html.erb
  25. +5 4 app/views/layouts/application.html.erb
  26. +1 1  app/views/sessions/new.html.erb
  27. +2 2 app/views/shared/_side.html.erb
  28. +1 1  app/views/spam_checks/_form.html.erb
  29. +2 2 app/views/spam_checks/index.html.erb
  30. +1 1  app/views/spam_questions/_form.html.erb
  31. +2 2 app/views/spam_questions/index.html.erb
  32. +5 5 app/views/spam_reports/index.html.erb
  33. +4 4 app/views/spam_reports/show.html.erb
  34. +2 2 app/views/sponsors/_form.html.erb
  35. +1 1  app/views/sponsors/index.html.erb
  36. +2 2 app/views/tags/show.html.erb
  37. +2 0  autotest/discover.rb
  38. +4 0 config.ru
  39. +49 0 config/application.rb
  40. +13 110 config/boot.rb
  41. +4 73 config/environment.rb
  42. +22 13 config/environments/development.rb
  43. +43 16 config/environments/production.rb
  44. +29 20 config/environments/test.rb
  45. +7 0 config/initializers/backtrace_silencers.rb
  46. +0 5 config/initializers/hoptoad.rb
  47. +2 2 config/initializers/inflections.rb
  48. +0 15 config/initializers/new_rails_defaults.rb
  49. +7 0 config/initializers/secret_token.rb
  50. +8 0 config/initializers/session_store.rb
  51. +5 0 config/locales/en.yml
  52. +0 3  config/preinitializer.rb
  53. +28 22 config/routes.rb
  54. +7 44 db/schema.rb
  55. +7 0 db/seeds.rb
  56. 0  lib/tasks/.gitkeep
  57. +0 181 lib/tasks/rspec.rake
  58. +24 31 public/404.html
  59. +24 31 public/422.html
  60. +24 31 public/500.html
  61. +0 10 public/dispatch.cgi
  62. +0 24 public/dispatch.fcgi
  63. +0 10 public/dispatch.rb
  64. +2 6 public/javascripts/application.js
  65. +0 963 public/javascripts/controls.js
  66. +0 973 public/javascripts/dragdrop.js
  67. +0 1,128 public/javascripts/effects.js
  68. +6,874 10 public/javascripts/jquery.js
  69. +166 0 public/javascripts/jquery.min.js
  70. +0 4,320 public/javascripts/prototype.js
  71. +156 0 public/javascripts/rails.js
  72. 0  public/stylesheets/.gitkeep
  73. +0 3  script/about
  74. +0 6 script/autospec
  75. +0 3  script/console
  76. +0 3  script/dbconsole
  77. +0 3  script/destroy
  78. +0 3  script/generate
  79. +0 3  script/performance/benchmarker
  80. +0 3  script/performance/profiler
  81. +0 3  script/performance/request
  82. +0 3  script/plugin
  83. +0 3  script/process/inspector
  84. +0 3  script/process/reaper
  85. +0 3  script/process/spawner
  86. +6 0 script/rails
  87. +0 3  script/runner
  88. +0 3  script/server
  89. +0 15 script/setup
  90. +0 4 script/setup_test
  91. +0 22 script/spec
  92. +0 52 script/spec_server
  93. +3 3 spec/controllers/comments_controller_spec.rb
  94. +6 6 spec/controllers/episodes_controller_spec.rb
  95. +1 1  spec/controllers/info_controller_spec.rb
  96. +1 1  spec/controllers/sessions_controller_spec.rb
  97. +2 2 spec/controllers/spam_checks_controller_spec.rb
  98. +2 2 spec/controllers/spam_questions_controller_spec.rb
  99. +4 4 spec/controllers/spam_reports_controller_spec.rb
  100. +2 2 spec/controllers/sponsors_controller_spec.rb
  101. +1 1  spec/controllers/tags_controller_spec.rb
  102. +0 2  spec/rcov.opts
  103. +0 4 spec/spec.opts
  104. +25 13 spec/spec_helper.rb
  105. 0  spec/{ → support}/controller_macros.rb
  106. 0  vendor/plugins/.gitkeep
  107. +0 47 vendor/plugins/hoptoad_notifier/INSTALL
  108. +0 112 vendor/plugins/hoptoad_notifier/README
  109. +0 22 vendor/plugins/hoptoad_notifier/Rakefile
  110. +0 1  vendor/plugins/hoptoad_notifier/install.rb
  111. +0 261 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb
  112. +0 50 vendor/plugins/hoptoad_notifier/tasks/hoptoad_notifier_tasks.rake
  113. +0 353 vendor/plugins/hoptoad_notifier/test/hoptoad_notifier_test.rb
10 .gitignore
... ... @@ -1,8 +1,10 @@
1   -log/*
2   -tmp/*
  1 +.bundle
  2 +db/*.sqlite3
  3 +log/*.log
  4 +log/*.pid
  5 +tmp/**/*
3 6 config/database.yml
4 7 config/app_config.yml
5 8 config/*.sphinx.conf
6   -db/*.sqlite3
7 9 db/sphinx
8   -public/assets
  10 +public/assets
1  .rspec
... ... @@ -0,0 +1 @@
  1 +--colour
24 Gemfile
... ... @@ -0,0 +1,24 @@
  1 +source 'http://rubygems.org'
  2 +
  3 +gem "rails", "3.0.3"
  4 +gem "mysql2"
  5 +gem "RedCloth"
  6 +gem "coderay"
  7 +gem "acts_as_list"
  8 +gem "thinking-sphinx", :require => "thinking_sphinx"
  9 +gem "whenever", :require => false
  10 +gem "will_paginate", ">= 3.0.pre2"
  11 +gem "jquery-rails"
  12 +
  13 +group :development, :test do
  14 + gem "mocha"
  15 + gem "rspec-rails"
  16 + gem "factory_girl_rails"
  17 + gem "webrat"
  18 + gem "autotest"
  19 + gem "autotest-rails"
  20 +end
  21 +
  22 +group :development do
  23 + gem "nifty-generators"
  24 +end
129 Gemfile.lock
... ... @@ -0,0 +1,129 @@
  1 +GEM
  2 + remote: http://rubygems.org/
  3 + specs:
  4 + RedCloth (4.2.3)
  5 + ZenTest (4.4.0)
  6 + aaronh-chronic (0.3.9)
  7 + abstract (1.0.0)
  8 + actionmailer (3.0.3)
  9 + actionpack (= 3.0.3)
  10 + mail (~> 2.2.9)
  11 + actionpack (3.0.3)
  12 + activemodel (= 3.0.3)
  13 + activesupport (= 3.0.3)
  14 + builder (~> 2.1.2)
  15 + erubis (~> 2.6.6)
  16 + i18n (~> 0.4)
  17 + rack (~> 1.2.1)
  18 + rack-mount (~> 0.6.13)
  19 + rack-test (~> 0.5.6)
  20 + tzinfo (~> 0.3.23)
  21 + activemodel (3.0.3)
  22 + activesupport (= 3.0.3)
  23 + builder (~> 2.1.2)
  24 + i18n (~> 0.4)
  25 + activerecord (3.0.3)
  26 + activemodel (= 3.0.3)
  27 + activesupport (= 3.0.3)
  28 + arel (~> 2.0.2)
  29 + tzinfo (~> 0.3.23)
  30 + activeresource (3.0.3)
  31 + activemodel (= 3.0.3)
  32 + activesupport (= 3.0.3)
  33 + activesupport (3.0.3)
  34 + acts_as_list (0.1.2)
  35 + arel (2.0.3)
  36 + autotest (4.4.1)
  37 + autotest-rails (4.1.0)
  38 + ZenTest
  39 + builder (2.1.2)
  40 + coderay (0.9.5)
  41 + diff-lcs (1.1.2)
  42 + erubis (2.6.6)
  43 + abstract (>= 1.0.0)
  44 + factory_girl (1.3.2)
  45 + factory_girl_rails (1.0)
  46 + factory_girl (~> 1.3)
  47 + rails (>= 3.0.0.beta4)
  48 + i18n (0.4.2)
  49 + jquery-rails (0.2.5)
  50 + rails (~> 3.0)
  51 + thor (~> 0.14.4)
  52 + mail (2.2.10)
  53 + activesupport (>= 2.3.6)
  54 + i18n (~> 0.4.1)
  55 + mime-types (~> 1.16)
  56 + treetop (~> 1.4.8)
  57 + mime-types (1.16)
  58 + mocha (0.9.9)
  59 + rake
  60 + mysql2 (0.2.6)
  61 + nifty-generators (0.4.2)
  62 + nokogiri (1.4.4)
  63 + polyglot (0.3.1)
  64 + rack (1.2.1)
  65 + rack-mount (0.6.13)
  66 + rack (>= 1.0.0)
  67 + rack-test (0.5.6)
  68 + rack (>= 1.0)
  69 + rails (3.0.3)
  70 + actionmailer (= 3.0.3)
  71 + actionpack (= 3.0.3)
  72 + activerecord (= 3.0.3)
  73 + activeresource (= 3.0.3)
  74 + activesupport (= 3.0.3)
  75 + bundler (~> 1.0)
  76 + railties (= 3.0.3)
  77 + railties (3.0.3)
  78 + actionpack (= 3.0.3)
  79 + activesupport (= 3.0.3)
  80 + rake (>= 0.8.7)
  81 + thor (~> 0.14.4)
  82 + rake (0.8.7)
  83 + riddle (1.2.1)
  84 + rspec (2.1.0)
  85 + rspec-core (~> 2.1.0)
  86 + rspec-expectations (~> 2.1.0)
  87 + rspec-mocks (~> 2.1.0)
  88 + rspec-core (2.1.0)
  89 + rspec-expectations (2.1.0)
  90 + diff-lcs (~> 1.1.2)
  91 + rspec-mocks (2.1.0)
  92 + rspec-rails (2.1.0)
  93 + rspec (~> 2.1.0)
  94 + thinking-sphinx (2.0.0)
  95 + activerecord (>= 3.0.0)
  96 + riddle (>= 1.2.0)
  97 + thor (0.14.4)
  98 + treetop (1.4.9)
  99 + polyglot (>= 0.3.1)
  100 + tzinfo (0.3.23)
  101 + webrat (0.7.2)
  102 + nokogiri (>= 1.2.0)
  103 + rack (>= 1.0)
  104 + rack-test (>= 0.5.3)
  105 + whenever (0.6.2)
  106 + aaronh-chronic (>= 0.3.9)
  107 + activesupport (>= 2.3.4)
  108 + will_paginate (3.0.pre2)
  109 +
  110 +PLATFORMS
  111 + ruby
  112 +
  113 +DEPENDENCIES
  114 + RedCloth
  115 + acts_as_list
  116 + autotest
  117 + autotest-rails
  118 + coderay
  119 + factory_girl_rails
  120 + jquery-rails
  121 + mocha
  122 + mysql2
  123 + nifty-generators
  124 + rails (= 3.0.3)
  125 + rspec-rails
  126 + thinking-sphinx
  127 + webrat
  128 + whenever
  129 + will_paginate (>= 3.0.pre2)
4 LICENSE
... ... @@ -1,4 +1,4 @@
1   -Copyright (c) 2008 Ryan Bates, Railscasts
  1 +Copyright (c) 2010 Ryan Bates, Railscasts
2 2
3 3 Permission is hereby granted, free of charge, to any person obtaining
4 4 a copy of this software and associated documentation files (the
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 17 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 18 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 19 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20   -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20 +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 Rakefile
... ... @@ -1,15 +1,7 @@
1 1 # Add your own tasks in files placed in lib/tasks ending in .rake,
2 2 # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3 3
4   -require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5   -
  4 +require File.expand_path('../config/application', __FILE__)
6 5 require 'rake'
7   -require 'rake/testtask'
8   -require 'rake/rdoctask'
9   -
10   -require 'tasks/rails'
11 6
12   -begin
13   - require 'thinking_sphinx/tasks'
14   -rescue MissingSourceFile
15   -end
  7 +Railscasts::Application.load_tasks
15 TODO
... ... @@ -1,15 +0,0 @@
1   -Fixes
2   -
3   -Features
4   -- add alternative download format for linux/windows
5   -- add search to comments page
6   -
7   -Possible
8   -- try "application/quicktime" content type to open movie directly in quicktime (see apple.com/quicktime for examples)
9   -- provide adobe media player feed
10   -- integration with miro (getmiro.com)
11   -+ improve CSS design
12   -+ author edit comment for short time
13   -+ textile for comments
14   -+ remember me when logging in
15   -+ add a blog
11 app/controllers/application_controller.rb
... ... @@ -1,14 +1,5 @@
1   -# Filters added to this controller apply to all controllers in the application.
2   -# Likewise, all the methods added will be available for all controllers.
3   -
4 1 class ApplicationController < ActionController::Base
5   - helper :all # include all helpers, all the time
6   -
7   - # See ActionController::RequestForgeryProtection for details
8   - # Uncomment the :secret if you're not using the cookie session store
9   - protect_from_forgery # :secret => 'fc8393e85d1780ae56953606f53014e1'
10   -
11   - include HoptoadNotifier::Catcher if APP_CONFIG['hoptoad_key']
  2 + protect_from_forgery
12 3
13 4 private
14 5
3  app/helpers/application_helper.rb
... ... @@ -1,6 +1,5 @@
1   -# Methods added to this helper will be available to all templates in the application.
2 1 module ApplicationHelper
3 2 def textilize(text)
4   - Textilizer.new(text).to_html unless text.blank?
  3 + Textilizer.new(text).to_html.html_safe unless text.blank?
5 4 end
6 5 end
23 app/helpers/error_messages_helper.rb
... ... @@ -0,0 +1,23 @@
  1 +module ErrorMessagesHelper
  2 + # Render error messages for the given objects. The :message and :header_message options are allowed.
  3 + def error_messages_for(*objects)
  4 + options = objects.extract_options!
  5 + options[:header_message] ||= "Invalid Fields"
  6 + options[:message] ||= "Correct the following errors and try again."
  7 + messages = objects.compact.map { |o| o.errors.full_messages }.flatten
  8 + unless messages.empty?
  9 + content_tag(:div, :class => "error_messages") do
  10 + list_items = messages.map { |msg| content_tag(:li, msg) }
  11 + content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe)
  12 + end
  13 + end
  14 + end
  15 +
  16 + module FormBuilderAdditions
  17 + def error_messages(options = {})
  18 + @template.error_messages_for(@object, options)
  19 + end
  20 + end
  21 +end
  22 +
  23 +ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)
11 app/helpers/layout_helper.rb
@@ -4,20 +4,19 @@
4 4 # helper :layout
5 5 module LayoutHelper
6 6 def title(page_title, show_title = true)
7   - @content_for_title = page_title.to_s
  7 + content_for(:title) { h(page_title.to_s) }
8 8 @show_title = show_title
9 9 end
10   -
  10 +
11 11 def show_title?
12 12 @show_title
13 13 end
14   -
  14 +
15 15 def stylesheet(*args)
16   - content_for(:head) { stylesheet_link_tag(*args.map(&:to_s)) }
  16 + content_for(:head) { stylesheet_link_tag(*args) }
17 17 end
18   -
  18 +
19 19 def javascript(*args)
20   - args = args.map { |arg| arg == :defaults ? arg : arg.to_s }
21 20 content_for(:head) { javascript_include_tag(*args) }
22 21 end
23 22 end
2  app/models/comment.rb
@@ -3,7 +3,7 @@ class Comment < ActiveRecord::Base
3 3
4 4 validates_presence_of :name, :content, :episode_id
5 5
6   - named_scope :recent, :order => "created_at DESC"
  6 + scope :recent, order("created_at DESC")
7 7
8 8 before_save :add_protocol_to_site_url
9 9
6 app/models/episode.rb
@@ -6,9 +6,9 @@ class Episode < ActiveRecord::Base
6 6
7 7 acts_as_list
8 8
9   - named_scope :published, lambda { {:conditions => ['published_at <= ?', Time.now.utc]} }
10   - named_scope :unpublished, lambda { {:conditions => ['published_at > ?', Time.now.utc]} }
11   - named_scope :recent, :order => 'position DESC'
  9 + scope :published, lambda { where('published_at <= ?', Time.now.utc) }
  10 + scope :unpublished, lambda { where('published_at > ?', Time.now.utc) }
  11 + scope :recent, order('position DESC')
12 12
13 13 validates_presence_of :published_at, :name
14 14 validates_associated :downloads, :on => :update # create automatically handles validation
2  app/models/spam_question.rb
@@ -2,6 +2,6 @@ class SpamQuestion < ActiveRecord::Base
2 2 attr_accessible :question, :answer
3 3
4 4 def self.random # there are more efficient ways to do this but it's database specific
5   - find(:first, :offset => rand(self.count-1))
  5 + find(:first, :offset => rand(self.count))
6 6 end
7 7 end
6 app/models/spam_report.rb
@@ -3,9 +3,9 @@ class SpamReport < ActiveRecord::Base
3 3
4 4 before_create :copy_comment_attributes
5 5
6   - named_scope :unconfirmed, :conditions => "confirmed_at is null"
7   - named_scope :confirmed, :conditions => "confirmed_at is not null"
8   - named_scope :popular, :order => "hit_count desc"
  6 + scope :unconfirmed, where("confirmed_at is null")
  7 + scope :confirmed, where("confirmed_at is not null")
  8 + scope :popular, order("hit_count desc")
9 9
10 10 def self.report_comment(comment)
11 11 if comment.matching_spam_reports.empty?
2  app/models/sponsor.rb
... ... @@ -1,5 +1,5 @@
1 1 class Sponsor < ActiveRecord::Base
2   - named_scope :active, :conditions => ["active = ?", true]
  2 + scope :active, where("active = ?", true)
3 3
4 4 def position
5 5 if force_top?
6 app/views/comments/_comment.html.erb
... ... @@ -1,18 +1,18 @@
1 1 <% @comment_counter ||= 0 -%>
2 2 <% @comment_counter += 1 -%>
3 3 <%= tag :hr if @comment_counter > 1 %>
4   -<% div_for comment do %>
  4 +<%= div_for comment do %>
5 5 <%- if comment.episode && !current_page?(comment.episode) -%>
6 6 <h4>
7 7 Episode #<%= comment.episode.position %>:
8   - <%= link_to h(comment.episode.name), episode_path(:id => comment.episode, :anchor => dom_id(comment)) %>
  8 + <%= link_to comment.episode.name, episode_path(:id => comment.episode, :anchor => dom_id(comment)) %>
9 9 </h4>
10 10 <%- end -%>
11 11 <%- if comment.position -%>
12 12 <span class="position"><%= comment.position %>.</span>
13 13 <%- end -%>
14 14 <span class="name">
15   - <%= link_to_unless comment.site_url.blank?, h(comment.name), h(comment.site_url), :rel => "nofollow" %>
  15 + <%= link_to_unless comment.site_url.blank?, comment.name, comment.site_url, :rel => "nofollow" %>
16 16 </span>
17 17 <%- unless comment.created_at.nil? -%>
18 18 <span class="created_at">
8 app/views/comments/_form.html.erb
... ... @@ -1,13 +1,13 @@
1   -<% form_for @comment do |f| %>
2   - <%= error_messages_for :comment %>
  1 +<%= form_for @comment do |f| %>
  2 + <%= f.error_messages %>
3 3 <noscript><p>Javascript required to add comment.</p></noscript>
4 4 <div>
5 5 <%= f.hidden_field :episode_id %>
6   - <%= enkode hidden_field_tag(:spam_key, APP_CONFIG['spam_key']) %>
  6 + <%= raw enkode(hidden_field_tag(:spam_key, APP_CONFIG['spam_key'])) %>
7 7 </div>
8 8 <% if current_spam_question %>
9 9 <p id="spam_question">
10   - <strong><%=h current_spam_question.question %></strong><br />
  10 + <strong><%= current_spam_question.question %></strong><br />
11 11 <%= text_field_tag :spam_answer %>
12 12 </p>
13 13 <% end %>
2  app/views/comments/index.html.erb
... ... @@ -1,5 +1,5 @@
1 1 <% title "Recent Comments" %>
2   -<% content_tag :head do %>
  2 +<% content_for :head do %>
3 3 <link rel="alternate" type="application/rss+xml" title="Comments RSS" href="http://feeds.feedburner.com/railscasts_comments" />
4 4 <% end %>
5 5
6 app/views/episodes/_episode.html.erb
@@ -11,13 +11,13 @@
11 11 <% end %>
12 12 </div>
13 13 <div class="main">
14   - <h2><%= link_to_unless_current h(episode.name), episode %></h2>
15   - <div class="description"><%=h episode.description %></div>
  14 + <h2><%= link_to_unless_current episode.name, episode %></h2>
  15 + <div class="description"><%= episode.description %></div>
16 16 <% unless episode.tags.empty? %>
17 17 <div class="tags">
18 18 Tags:
19 19 <% for tag in episode.tags %>
20   - <%= link_to h(tag.name), tag %>
  20 + <%= link_to tag.name, tag %>
21 21 <% end %>
22 22 </div>
23 23 <% end %>
10 app/views/episodes/_form.html.erb
... ... @@ -1,6 +1,6 @@
1 1 <div class="content">
2   - <%= error_messages_for :episode %>
3   - <% form_for @episode do |f| %>
  2 + <%= form_for @episode do |f| %>
  3 + <%= f.error_messages %>
4 4 <p>
5 5 <%= f.label :name %><br />
6 6 <%= f.text_field :name %>
@@ -30,9 +30,9 @@
30 30 <%= f.label :asciicasts, "Available on ASCIIcasts" %>
31 31 </p>
32 32 <% for download in @episode.downloads %>
33   - <% fields_for_download(download) do |d| %>
34   - <%= error_messages_for :download, :object => download %>
35   - <h3><%=h download.format %></h3>
  33 + <%= fields_for_download(download) do |d| %>
  34 + <%= d.error_messages %>
  35 + <h3><%= download.format %></h3>
36 36 <div><%= d.hidden_field :format %></div>
37 37 <p>
38 38 <%= d.label :url, 'File URL' %><br />
4 app/views/episodes/archive.html.erb
... ... @@ -1,7 +1,7 @@
1 1 <% title "All Episodes" %>
2 2
3 3 <div class="content">
4   - <% form_tag archive_episodes_path, :method => 'get' do %>
  4 + <%= form_tag archive_episodes_path, :method => 'get' do %>
5 5 <p>
6 6 <%= text_field_tag :search, params[:search] %>
7 7 <%= submit_tag "Search", :name => nil %>
@@ -9,7 +9,7 @@
9 9 <% end %>
10 10
11 11 <% @episode_months.each do |month, episodes| %>
12   - <h2><%=h month.strftime('%B %Y') %></h2>
  12 + <h2><%= month.strftime('%B %Y') %></h2>
13 13 <% for episode in episodes %>
14 14 <div>
15 15 <%= episode.position %>.
6 app/views/episodes/index.html.erb
... ... @@ -1,6 +1,6 @@
1 1 <% title "Free Ruby on Rails Screencasts", false %>
2 2
3   -<% form_tag episodes_path, :method => 'get' do %>
  3 +<%= form_tag episodes_path, :method => 'get' do %>
4 4 <p class="content">
5 5 <%= text_field_tag :search, params[:search] %>
6 6 <%= submit_tag "Search", :name => nil %>
@@ -16,9 +16,9 @@
16 16 <% end %>
17 17
18 18 <p class="content">
19   - <%= link_to h('< Previous Page'), :overwrite_params => { :page => @episodes.previous_page } if @episodes.previous_page %>
  19 + <%= link_to '< Previous Page', :overwrite_params => { :page => @episodes.previous_page } if @episodes.previous_page %>
20 20 <%= "|" if @episodes.previous_page && @episodes.next_page %>
21   - <%= link_to h('Next Page >'), :overwrite_params => { :page => @episodes.next_page } if @episodes.next_page %>
  21 + <%= link_to 'Next Page >', :overwrite_params => { :page => @episodes.next_page } if @episodes.next_page %>
22 22 </p>
23 23
24 24 <% if admin? %>
8 app/views/episodes/show.html.erb
... ... @@ -1,20 +1,20 @@
1 1 <% title @episode.name, false %>
2 2
3   -<% content_tag :head do %>
  3 +<% content_for :head do %>
4 4 <link rel="alternate" type="application/rss+xml" title="Episode Comments RSS" href="<%= episode_url(@episode, :format => 'rss') %>" />
5 5 <% end %>
6 6
7 7 <div class="episodes">
8   - <% render :layout => @episode do %>
  8 + <%= render :layout => @episode do %>
9 9 <div class="notes">
10 10 <%= textilize @episode.notes %>
11 11 </div>
12 12 <div id="episode_nav">
13 13 <% unless @episode.first? %>
14   - <div id="previous_episode"><%= link_to h('< Previous Episode'), @episode.higher_item %></div>
  14 + <div id="previous_episode"><%= link_to '< Previous Episode', @episode.higher_item %></div>
15 15 <% end %>
16 16 <% unless @episode.last_published? || @episode.last? %>
17   - <div id="next_episode"><%= link_to h('Next Episode >'), @episode.lower_item %></div>
  17 + <div id="next_episode"><%= link_to 'Next Episode >', @episode.lower_item %></div>
18 18 <% end %>
19 19 </div>
20 20 <div class="clear"></div>
9 app/views/layouts/application.html.erb
@@ -3,12 +3,13 @@
3 3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 4 <head>
5 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6   - <title>Railscasts - <%= h(yield(:title) || "Free Ruby on Rails Screencasts") %></title>
  6 + <title>Railscasts - <%= content_for?(:title) ? yield(:title) : "Free Ruby on Rails Screencasts" %></title>
7 7 <meta name="description" content="Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced programmers." />
8 8 <meta name="keywords" content="rails, ruby on rails, screencasts, railscast, railscasts, tips, tricks, tutorials, training, podcasts, programming" />
9 9 <link rel="alternate" type="application/rss+xml" title="Episodes RSS" href="http://feeds.feedburner.com/railscasts" />
10 10 <%= stylesheet_link_tag 'application', 'coderay' %>
11   - <%= javascript_include_tag 'jquery', 'application' %>
  11 + <%= javascript_include_tag :defaults %>
  12 + <%= csrf_meta_tag %>
12 13 <%= yield(:head) %>
13 14 </head>
14 15 <body>
@@ -20,13 +21,13 @@
20 21 <%- end -%>
21 22
22 23 <%- if show_title? -%>
23   - <h1 class="content"><%=h yield(:title) %></h1>
  24 + <h1 class="content"><%= yield(:title) %></h1>
24 25 <%- end -%>
25 26
26 27 <%= yield %>
27 28 </div>
28 29 <div id="side">
29   - <%= yield(:side) || render(:partial => 'shared/side') %>
  30 + <%= content_for?(:side) ? yield(:side) : render(:partial => 'shared/side') %>
30 31 </div>
31 32 <div class="clear"></div>
32 33 </div>
2  app/views/sessions/new.html.erb
... ... @@ -1,7 +1,7 @@
1 1 <% title "Login" %>
2 2
3 3 <div class="content">
4   - <% form_tag sessions_path do %>
  4 + <%= form_tag sessions_path do %>
5 5 <p>
6 6 <%= label_tag 'password', 'Password:' %>
7 7 <%= password_field_tag 'password' %>
4 app/views/shared/_side.html.erb
@@ -9,7 +9,7 @@
9 9 <strong>sponsored by:</strong>
10 10 <% for sponsor in Sponsor.active.sort_by(&:position) %>
11 11 <div class="sponsor">
12   - <%= link_to image_tag(sponsor.image_url, :alt => h(sponsor.name)), sponsor.site_url %>
  12 + <%= link_to image_tag(sponsor.image_url, :alt => sponsor.name), sponsor.site_url %>
13 13 </div>
14 14 <% end %>
15 15 </div>
@@ -17,7 +17,7 @@
17 17 <strong>tags:</strong>
18 18 <ul id="tags">
19 19 <% for tag in Tag.find(:all, :order => 'name') %>
20   - <li><%= link_to h(tag.name), tag_path(tag) %></li>
  20 + <li><%= link_to tag.name, tag_path(tag) %></li>
21 21 <% end %>
22 22 </ul>
23 23 </div>
2  app/views/spam_checks/_form.html.erb
... ... @@ -1,4 +1,4 @@
1   -<% form_for @spam_check do |f| %>
  1 +<%= form_for @spam_check do |f| %>
2 2 <%= f.error_messages %>
3 3 <p>
4 4 <%= f.label :regexp %><br />
4 app/views/spam_checks/index.html.erb
@@ -11,8 +11,8 @@
11 11 </tr>
12 12 <% for spam_check in @spam_checks %>
13 13 <tr>
14   - <td><%=h spam_check.regexp %></td>
15   - <td><%=h spam_check.weight %></td>
  14 + <td><%= spam_check.regexp %></td>
  15 + <td><%= spam_check.weight %></td>
16 16 <td><%= link_to "edit", edit_spam_check_path(spam_check) %></td>
17 17 <td><%= link_to "destroy", spam_check, :method => :delete, :confirm => "Are you sure?" %></td>
18 18 </tr>
2  app/views/spam_questions/_form.html.erb
... ... @@ -1,4 +1,4 @@
1   -<% form_for @spam_question do |f| %>
  1 +<%= form_for @spam_question do |f| %>
2 2 <%= f.error_messages %>
3 3 <p>
4 4 <%= f.label :question %><br />
4 app/views/spam_questions/index.html.erb
@@ -11,8 +11,8 @@
11 11 </tr>
12 12 <% for spam_question in @spam_questions %>
13 13 <tr>
14   - <td><%=h spam_question.question %></td>
15   - <td><%=h spam_question.answer %></td>
  14 + <td><%= spam_question.question %></td>
  15 + <td><%= spam_question.answer %></td>
16 16 <td><%= link_to "Edit", edit_spam_question_path(spam_question) %></td>
17 17 <td><%= link_to "Destroy", spam_question, :confirm => 'Are you sure?', :method => :delete %></td>
18 18 </tr>
10 app/views/spam_reports/index.html.erb
@@ -4,7 +4,7 @@
4 4 <%= render :partial => 'shared/navigation' %>
5 5 <% end %>
6 6
7   -<% form_tag confirm_spam_reports_path do %>
  7 +<%= form_tag confirm_spam_reports_path do %>
8 8 <table border="1" cellspacing="0" cellpadding="3" id="spam_reports">
9 9 <tr>
10 10 <th></th>
@@ -16,10 +16,10 @@
16 16 <% for spam_report in @spam_reports %>
17 17 <tr>
18 18 <td><%= check_box_tag "id[]", spam_report.id, false %></td>
19   - <td><%= link_to h(spam_report.comment_name), spam_report %></td>
20   - <td><%=h spam_report.comment_ip %></td>
21   - <td><%=h spam_report.comment_site_url %></td>
22   - <td><%=h spam_report.hit_count %></td>
  19 + <td><%= link_to spam_report.comment_name, spam_report %></td>
  20 + <td><%= spam_report.comment_ip %></td>
  21 + <td><%= spam_report.comment_site_url %></td>
  22 + <td><%= spam_report.hit_count %></td>
23 23 </tr>
24 24 <% end %>
25 25 </table>
8 app/views/spam_reports/show.html.erb
@@ -6,24 +6,24 @@
6 6 <% unless @spam_report.comment_ip.blank? %>
7 7 <p>
8 8 <strong>IP Address:</strong>
9   - <%=h @spam_report.comment_ip %>
  9 + <%= @spam_report.comment_ip %>
10 10 </p>
11 11 <% end %>
12 12 <% unless @spam_report.comment_site_url.blank? %>
13 13 <p>
14 14 <strong>Site URL:</strong>
15   - <%=h @spam_report.comment_site_url %>
  15 + <%= @spam_report.comment_site_url %>
16 16 </p>
17 17 <% end %>
18 18 <% unless @spam_report.comment_name.blank? %>
19 19 <p>
20 20 <strong>Author Name:</strong>
21   - <%=h @spam_report.comment_name %>
  21 + <%= @spam_report.comment_name %>
22 22 </p>
23 23 <% end %>
24 24 <p>
25 25 <strong>Number of Hits:</strong>
26   - <%=h @spam_report.hit_count %>
  26 + <%= @spam_report.hit_count %>
27 27 </p>
28 28
29 29 <p>Look through the comments below and confirm this spam report by choosing confirm at the bottom. Otherwise you can <%= link_to 'destroy it', @spam_report, :confirm => 'Are you sure?', :method => :delete %>.</p>
4 app/views/sponsors/_form.html.erb
... ... @@ -1,6 +1,6 @@
1 1 <div class="content">
2   - <%= error_messages_for :sponsor %>
3   - <% form_for @sponsor do |f| %>
  2 + <%= form_for @sponsor do |f| %>
  3 + <%= f.error_messages %>
4 4 <p>
5 5 <%= f.label :name %><br />
6 6 <%= f.text_field :name %>
2  app/views/sponsors/index.html.erb
@@ -2,7 +2,7 @@
2 2 <div class="content">
3 3 <% for sponsor in @sponsors %>
4 4 <div class="sponsor">
5   - <h3><%=h sponsor.name %></h3>
  5 + <h3><%= sponsor.name %></h3>
6 6 <p><%= image_tag(sponsor.image_url) %></p>
7 7 <p class="actions">
8 8 <%= link_to "Edit", edit_sponsor_path(sponsor) %> |
4 app/views/tags/show.html.erb
@@ -5,7 +5,7 @@
5 5 </div>
6 6
7 7 <p class="content">
8   - <%= link_to h('< Previous Page'), :overwrite_params => { :page => @episodes.previous_page } if @episodes.previous_page %>
  8 + <%= link_to '< Previous Page', :overwrite_params => { :page => @episodes.previous_page } if @episodes.previous_page %>
9 9 <%= "|" if @episodes.previous_page && @episodes.next_page %>
10   - <%= link_to h('Next Page >'), :overwrite_params => { :page => @episodes.next_page } if @episodes.next_page %>
  10 + <%= link_to 'Next Page >', :overwrite_params => { :page => @episodes.next_page } if @episodes.next_page %>
11 11 </p>
2  autotest/discover.rb
... ... @@ -0,0 +1,2 @@
  1 +Autotest.add_discovery { "rails" }
  2 +Autotest.add_discovery { "rspec2" }
4 config.ru
... ... @@ -0,0 +1,4 @@
  1 +# This file is used by Rack-based servers to start the application.
  2 +
  3 +require ::File.expand_path('../config/environment', __FILE__)
  4 +run Railscasts::Application
49 config/application.rb
... ... @@ -0,0 +1,49 @@
  1 +require File.expand_path('../boot', __FILE__)
  2 +
  3 +require 'yaml'
  4 +APP_CONFIG = YAML.load(File.read(File.expand_path('../app_config.yml', __FILE__)))
  5 +
  6 +require 'rails/all'
  7 +
  8 +# If you have a Gemfile, require the gems listed there, including any gems
  9 +# you've limited to :test, :development, or :production.
  10 +Bundler.require(:default, Rails.env) if defined?(Bundler)
  11 +
  12 +module Railscasts
  13 + class Application < Rails::Application
  14 + # Settings in config/environments/* take precedence over those specified here.
  15 + # Application configuration should go into files in config/initializers
  16 + # -- all .rb files in that directory are automatically loaded.
  17 +
  18 + # Custom directories with classes and modules you want to be autoloadable.
  19 + # config.autoload_paths += %W(#{config.root}/extras)
  20 +
  21 + # Only load the plugins named here, in the order given (default is alphabetical).
  22 + # :all can be used as a placeholder for all plugins not explicitly named.
  23 + # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
  24 +
  25 + # Activate observers that should always be running.
  26 + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
  27 +
  28 + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
  29 + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
  30 + # config.time_zone = 'Central Time (US & Canada)'
  31 +
  32 + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
  33 + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
  34 + # config.i18n.default_locale = :de
  35 +
  36 + # JavaScript files you want as :defaults (application.js is always included).
  37 + # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
  38 +
  39 + # Configure the default encoding used in templates for Ruby 1.9.
  40 + config.encoding = "utf-8"
  41 +
  42 + # Configure sensitive parameters which will be filtered from the log file.
  43 + config.filter_parameters += [:password]
  44 +
  45 + config.time_zone = 'Pacific Time (US & Canada)'
  46 +
  47 + config.autoload_paths += %W(#{Rails.root}/lib)
  48 + end
  49 +end
123 config/boot.rb
... ... @@ -1,110 +1,13 @@
1   -# Don't change this file!
2   -# Configure your app in config/environment.rb and config/environments/*.rb
3   -
4   -RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5   -
6   -module Rails
7   - class << self
8   - def boot!
9   - unless booted?
10   - preinitialize
11   - pick_boot.run
12   - end
13   - end
14   -
15   - def booted?
16   - defined? Rails::Initializer
17   - end
18   -
19   - def pick_boot
20   - (vendor_rails? ? VendorBoot : GemBoot).new
21   - end
22   -
23   - def vendor_rails?
24   - File.exist?("#{RAILS_ROOT}/vendor/rails")
25   - end
26   -
27   - def preinitialize
28   - load(preinitializer_path) if File.exist?(preinitializer_path)
29   - end
30   -
31   - def preinitializer_path
32   - "#{RAILS_ROOT}/config/preinitializer.rb"
33   - end
34   - end
35   -
36   - class Boot
37   - def run
38   - load_initializer
39   - Rails::Initializer.run(:set_load_path)
40   - end
41   - end
42   -
43   - class VendorBoot < Boot
44   - def load_initializer
45   - require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46   - Rails::Initializer.run(:install_gem_spec_stubs)
47   - Rails::GemDependency.add_frozen_gem_path
48   - end
49   - end
50   -
51   - class GemBoot < Boot
52   - def load_initializer
53   - self.class.load_rubygems
54   - load_rails_gem
55   - require 'initializer'
56   - end
57   -
58   - def load_rails_gem
59   - if version = self.class.gem_version
60   - gem 'rails', version
61   - else
62   - gem 'rails'
63   - end
64   - rescue Gem::LoadError => load_error
65   - $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66   - exit 1
67   - end
68   -
69   - class << self
70   - def rubygems_version
71   - Gem::RubyGemsVersion rescue nil
72   - end
73   -
74   - def gem_version
75   - if defined? RAILS_GEM_VERSION
76   - RAILS_GEM_VERSION
77   - elsif ENV.include?('RAILS_GEM_VERSION')
78   - ENV['RAILS_GEM_VERSION']
79   - else
80   - parse_gem_version(read_environment_rb)
81   - end
82   - end
83   -
84   - def load_rubygems
85   - require 'rubygems'
86   - min_version = '1.3.1'
87   - unless rubygems_version >= min_version
88   - $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89   - exit 1
90   - end
91   -
92   - rescue LoadError
93   - $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94   - exit 1
95   - end
96   -
97   - def parse_gem_version(text)
98   - $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99   - end
100   -
101   - private
102   - def read_environment_rb
103   - File.read("#{RAILS_ROOT}/config/environment.rb")
104   - end
105   - end
106   - end
107   -end
108   -
109   -# All that for this:
110   -Rails.boot!
  1 +require 'rubygems'
  2 +
  3 +# Set up gems listed in the Gemfile.
  4 +gemfile = File.expand_path('../../Gemfile', __FILE__)
  5 +begin
  6 + ENV['BUNDLE_GEMFILE'] = gemfile
  7 + require 'bundler'
  8 + Bundler.setup
  9 +rescue Bundler::GemNotFound => e
  10 + STDERR.puts e.message
  11 + STDERR.puts "Try running `bundle install`."
  12 + exit!
  13 +end if File.exist?(gemfile)
77 config/environment.rb
... ... @@ -1,74 +1,5 @@
1   -# Be sure to restart your server when you modify this file
  1 +# Load the rails application
  2 +require File.expand_path('../application', __FILE__)
2 3
3   -# Uncomment below to force Rails into production mode when
4   -# you don't control web/app server and can't set it the proper way
5   -# ENV['RAILS_ENV'] ||= 'production'
6   -
7   -# Specifies gem version of Rails to use when vendor/rails is not present
8   -RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
9   -
10   -# Bootstrap the Rails environment, frameworks, and default configuration
11   -require File.join(File.dirname(__FILE__), 'boot')
12   -
13   -Rails::Initializer.run do |config|
14   - # Settings in config/environments/* take precedence over those specified here.
15   - # Application configuration should go into files in config/initializers
16   - # -- all .rb files in that directory are automatically loaded.
17   - # See Rails::Configuration for more options.
18   -
19   - # Skip frameworks you're not going to use. To use Rails without a database
20   - # you must remove the Active Record framework.
21   - # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
22   -
23   - # Specify gems that this application depends on.
24   - # They can then be installed with "rake gems:install" on new installations.
25   - # config.gem "bj"
26   - # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
27   - # config.gem "aws-s3", :lib => "aws/s3"
28   -
29   - # Only load the plugins named here, in the order given. By default, all plugins
30   - # in vendor/plugins are loaded in alphabetical order.
31   - # :all can be used as a placeholder for all plugins not explicitly named
32   - # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
33   -
34   - # Add additional load paths for your own custom dirs
35   - # config.load_paths += %W( #{RAILS_ROOT}/extras )
36   -
37   - # Force all environments to use the same logger level
38   - # (by default production uses :info, the others :debug)
39   - # config.log_level = :debug
40   -
41   - # Make Time.zone default to the specified zone, and make Active Record store time values
42   - # in the database in UTC, and return them converted to the specified local zone.
43   - # Run "rake -D time" for a list of tasks for finding time zone names. Uncomment to use default local time.
44   - config.time_zone = 'Pacific Time (US & Canada)'
45   -
46   - # Your secret key for verifying cookie session data integrity.
47   - # If you change this key, all old sessions will become invalid!
48   - # Make sure the secret is at least 30 characters and all random,
49   - # no regular words or you'll be exposed to dictionary attacks.
50   - config.action_controller.session = {
51   - :session_key => APP_CONFIG['session_key'],
52   - :secret => APP_CONFIG['session_secret']
53   - }
54   -
55   - # Use the database for sessions instead of the cookie-based default,
56   - # which shouldn't be used to store highly confidential information
57   - # (create the session table with "rake db:sessions:create")
58   - # config.action_controller.session_store = :active_record_store
59   -
60   - # Use SQL instead of Active Record's schema dumper when creating the test database.
61   - # This is necessary if your schema can't be completely dumped by the schema dumper,
62   - # like if you have constraints or database-specific column types
63   - # config.active_record.schema_format = :sql
64   -
65   - # Activate observers that should always be running
66   - # config.active_record.observers = :cacher, :garbage_collector
67   -
68   - config.gem "RedCloth", :lib => 'redcloth', :version => ">= 4.0"
69   - config.gem "coderay"
70   - config.gem 'ryanb-acts-as-list', :lib => 'acts_as_list', :source => 'http://gems.github.com'
71   - config.gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com'
72   - config.gem 'ryanb-thinking-sphinx', :lib => 'thinking_sphinx', :source => 'http://gems.github.com'
73   - config.gem 'javan-whenever', :lib => false, :source => 'http://gems.github.com'
74   -end
  4 +# Initialize the rails application
  5 +Railscasts::Application.initialize!
35 config/environments/development.rb
... ... @@ -1,17 +1,26 @@
1   -# Settings specified here will take precedence over those in config/environment.rb
  1 +Railscasts::Application.configure do
  2 + # Settings specified here will take precedence over those in config/application.rb
2 3
3   -# In the development environment your application's code is reloaded on
4   -# every request. This slows down response time but is perfect for development
5   -# since you don't have to restart the webserver when you make code changes.
6   -config.cache_classes = false
  4 + # In the development environment your application's code is reloaded on
  5 + # every request. This slows down response time but is perfect for development
  6 + # since you don't have to restart the webserver when you make code changes.
  7 + config.cache_classes = false
7 8
8   -# Log error messages when you accidentally call methods on nil.
9   -config.whiny_nils = true
  9 + # Log error messages when you accidentally call methods on nil.
  10 + config.whiny_nils = true
10 11
11   -# Show full error reports and disable caching
12   -config.action_controller.consider_all_requests_local = true
13   -config.action_view.debug_rjs = true
14   -config.action_controller.perform_caching = false
  12 + # Show full error reports and disable caching
  13 + config.consider_all_requests_local = true
  14 + config.action_view.debug_rjs = true
  15 + config.action_controller.perform_caching = false
  16 +
  17 + # Don't care if the mailer can't send
  18 + config.action_mailer.raise_delivery_errors = false
  19 +
  20 + # Print deprecation notices to the Rails logger
  21 + config.active_support.deprecation = :log
  22 +
  23 + # Only use best-standards-support built into browsers
  24 + config.action_dispatch.best_standards_support = :builtin
  25 +end
15 26
16   -# Don't care if the mailer can't send
17   -config.action_mailer.raise_delivery_errors = false
59 config/environments/production.rb
... ... @@ -1,22 +1,49 @@
1   -# Settings specified here will take precedence over those in config/environment.rb
  1 +Railscasts::Application.configure do
  2 + # Settings specified here will take precedence over those in config/application.rb
2 3
3   -# The production environment is meant for finished, "live" apps.
4   -# Code is not reloaded between requests
5   -config.cache_classes = true
  4 + # The production environment is meant for finished, "live" apps.
  5 + # Code is not reloaded between requests
  6 + config.cache_classes = true
6 7
7   -# Use a different logger for distributed setups
8   -# config.logger = SyslogLogger.new
  8 + # Full error reports are disabled and caching is turned on
  9 + config.consider_all_requests_local = false
  10 + config.action_controller.perform_caching = true
9 11
10   -# Full error reports are disabled and caching is turned on
11   -config.action_controller.consider_all_requests_local = false
12   -config.action_controller.perform_caching = true
13   -config.action_view.cache_template_loading = true
  12 + # Specifies the header that your server uses for sending files
  13 + config.action_dispatch.x_sendfile_header = "X-Sendfile"
14 14
15   -# Use a different cache store in production
16   -# config.cache_store = :mem_cache_store
  15 + # For nginx:
  16 + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17 17
18   -# Enable serving of images, stylesheets, and javascripts from an asset server
19   -# config.action_controller.asset_host = "http://assets.example.com"
  18 + # If you have no front-end server that supports something like X-Sendfile,
  19 + # just comment this out and Rails will serve the files
20 20
21   -# Disable delivery errors, bad email addresses will be ignored
22   -# config.action_mailer.raise_delivery_errors = false
  21 + # See everything in the log (default is :info)
  22 + # config.log_level = :debug
  23 +
  24 + # Use a different logger for distributed setups
  25 + # config.logger = SyslogLogger.new
  26 +
  27 + # Use a different cache store in production
  28 + # config.cache_store = :mem_cache_store
  29 +
  30 + # Disable Rails's static asset server
  31 + # In production, Apache or nginx will already do this
  32 + config.serve_static_assets = false
  33 +
  34 + # Enable serving of images, stylesheets, and javascripts from an asset server
  35 + # config.action_controller.asset_host = "http://assets.example.com"
  36 +
  37 + # Disable delivery errors, bad email addresses will be ignored
  38 + # config.action_mailer.raise_delivery_errors = false
  39 +
  40 + # Enable threaded mode
  41 + # config.threadsafe!
  42 +
  43 + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  44 + # the I18n.default_locale when a translation can not be found)
  45 + config.i18n.fallbacks = true
  46 +
  47 + # Send deprecation notices to registered listeners
  48 + config.active_support.deprecation = :notify
  49 +end
49 config/environments/test.rb
... ... @@ -1,26 +1,35 @@
1   -# Settings specified here will take precedence over those in config/environment.rb
  1 +Railscasts::Application.configure do