Permalink
Browse files

Server starts up after Rails 3 upgrade

  • Loading branch information...
1 parent 7d1962e commit 41352cf0c8faaca8068e0fb63a3a405e54e8cfc7 @chinmaygarde committed Dec 13, 2010
Showing with 2,480 additions and 382 deletions.
  1. +14 −16 Gemfile
  2. +2 −8 Rakefile
  3. +1 −8 app/controllers/application_controller.rb
  4. +26 −0 app/controllers/application_controller.rb.rails2
  5. +12 −0 app/helpers/application_helper.rb.rails2
  6. +4 −0 config.ru
  7. +44 −0 config/application.rb
  8. +13 −115 config/boot.rb
  9. +17 −0 config/database.yml.rails2
  10. +4 −39 config/environment.rb
  11. +40 −0 config/environment.rb.rails2
  12. +19 −24 config/environments/development.rb
  13. +31 −0 config/environments/development.rb.rails2
  14. +41 −20 config/environments/production.rb
  15. +28 −0 config/environments/production.rb.rails2
  16. +28 −23 config/environments/test.rb
  17. +2 −2 config/initializers/backtrace_silencers.rb
  18. +1 −1 config/initializers/inflections.rb
  19. +1 −1 config/initializers/mime_types.rb
  20. +0 −21 config/initializers/new_rails_defaults.rb
  21. +7 −0 config/initializers/secret_token.rb
  22. +3 −10 config/initializers/session_store.rb
  23. +1 −1 config/locales/en.yml
  24. +67 −36 config/routes.rb
  25. +58 −0 config/routes.rb.rails2
  26. 0 lib/tasks/.gitkeep
  27. +3 −1 lib/tasks/resque.rake
  28. +1 −0 lib/tasks/sphinx.rake
  29. +15 −19 public/404.html
  30. +15 −19 public/422.html
  31. +14 −18 public/500.html
  32. BIN public/images/rails.png
  33. +239 −0 public/index.html
  34. 0 public/javascripts/.gitkeep
  35. 0 public/stylesheets/.gitkeep
  36. +6 −0 script/rails
  37. 0 vendor/plugins/.gitkeep
  38. +20 −0 vendor/plugins/rails_upgrade/MIT-LICENSE
  39. +20 −0 vendor/plugins/rails_upgrade/README
  40. +22 −0 vendor/plugins/rails_upgrade/Rakefile
  41. +2 −0 vendor/plugins/rails_upgrade/init.rb
  42. +38 −0 vendor/plugins/rails_upgrade/install.rb
  43. +472 −0 vendor/plugins/rails_upgrade/lib/application_checker.rb
  44. +95 −0 vendor/plugins/rails_upgrade/lib/gemfile_generator.rb
  45. +51 −0 vendor/plugins/rails_upgrade/lib/new_configuration_generator.rb
  46. 0 vendor/plugins/rails_upgrade/lib/rails_upgrade.rb
  47. +349 −0 vendor/plugins/rails_upgrade/lib/routes_upgrader.rb
  48. +78 −0 vendor/plugins/rails_upgrade/lib/tasks/rails_upgrade_tasks.rake
  49. +293 −0 vendor/plugins/rails_upgrade/test/application_checker_test.rb
  50. +72 −0 vendor/plugins/rails_upgrade/test/gemfile_generator_test.rb
  51. +63 −0 vendor/plugins/rails_upgrade/test/new_configuration_generator_test.rb
  52. +142 −0 vendor/plugins/rails_upgrade/test/routes_upgrader_test.rb
  53. +5 −0 vendor/plugins/rails_upgrade/test/test_helper.rb
  54. +1 −0 vendor/plugins/rails_upgrade/uninstall.rb
View
30 Gemfile
@@ -1,48 +1,46 @@
source :gemcutter
-gem "bundler"
-
# Well, duh..
-gem "rails", "2.3.8"
+gem "rails", "3.0.3"
# Authentication
-gem "devise", "1.0.8"
+gem "devise"
# Role Management
-gem "cancan", "1.4.0"
+gem "cancan"
# Databases
-gem "mysql", "2.8.1"
+gem "mysql"
# Background Jobs
-gem "resque", "1.10.0"
+gem "resque"
# Delayed and recurring jobs
-gem "resque-scheduler", "1.9.6"
+gem "resque-scheduler"
# Full text search
-gem "thinking-sphinx", "1.3.11", :require => "thinking_sphinx"
+gem "thinking-sphinx", :require => "thinking_sphinx"
# Attachments
-gem "paperclip", "2.3.4"
+gem "paperclip"
group :development, :test do
# Database: Switch to mysql as soon as possible
gem "sqlite3-ruby", :require => "sqlite3"
# RSpec
- gem "rspec", "1.3.0"
- gem "rspec-rails", "1.3.2"
+ gem "rspec"
+ gem "rspec-rails"
# Factory Replacement
- gem "factory_girl", "1.3.2"
+ gem "factory_girl_rails"
# Continuous Testing
- gem "ZenTest", "4.4.0"
+ gem "ZenTest"
# Test Coverage Reporting
- gem "rcov", "0.9.9"
+ gem "rcov"
# Rake Replacement
- gem "thor", "0.14.2"
+ gem "thor"
end
View
@@ -1,13 +1,7 @@
# 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 File.expand_path('../config/application', __FILE__)
require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-require 'tasks/rails'
-require 'resque/tasks'
-require 'resque_scheduler/tasks'
-require 'thinking_sphinx/tasks'
+OaspCookieOverflow::Application.load_tasks
@@ -1,12 +1,5 @@
-# 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
- #protect_from_forgery # See ActionController::RequestForgeryProtection for details
- filter_parameter_logging :password
- before_filter :prepare_format
-
+ protect_from_forgery
private
def is_mobile?
@@ -0,0 +1,26 @@
+# 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
+ #protect_from_forgery # See ActionController::RequestForgeryProtection for details
+ filter_parameter_logging :password
+ before_filter :prepare_format
+
+ private
+
+ def is_mobile?
+ if session[:go_mobile]
+ session[:go_mobile] == "1"
+ else
+ request.user_agent =~ /Mobile|webOS/
+ end
+ end
+
+ helper_method :is_mobile?
+
+ def prepare_format
+ session[:go_mobile] = params[:mobile] if params[:mobile]
+ request.format = :mobile if is_mobile?
+ end
+end
@@ -0,0 +1,12 @@
+module ApplicationHelper
+ def gravatar(arg)
+ if arg.kind_of? User
+ email = arg.email
+ elsif arg.kind_of? String
+ email = arg
+ else
+ email = "nothing"
+ end
+ "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email)}.jpg"
+ end
+end
View
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run OaspCookieOverflow::Application
View
@@ -0,0 +1,44 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+# If you have a Gemfile, require the gems listed there, including any gems
+# you've limited to :test, :development, or :production.
+Bundler.require(:default, Rails.env) if defined?(Bundler)
+
+module OaspCookieOverflow
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+ config.autoload_paths += %W( #{config.root}/app/jobs )
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+ config.time_zone = 'Eastern Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # JavaScript files you want as :defaults (application.js is always included).
+ config.action_view.javascript_expansions[:defaults] = %w()
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+ end
+end
View
@@ -1,115 +1,13 @@
-# Don't change this file!
-# Configure your app in config/environment.rb and config/environments/*.rb
-
-RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
-
-module Rails
- class << self
- def boot!
- unless booted?
- preinitialize
- pick_boot.run
- end
- end
-
- def booted?
- defined? Rails::Initializer
- end
-
- def pick_boot
- (vendor_rails? ? VendorBoot : GemBoot).new
- end
-
- def vendor_rails?
- File.exist?("#{RAILS_ROOT}/vendor/rails")
- end
-
- def preinitialize
- load(preinitializer_path) if File.exist?(preinitializer_path)
- end
-
- def preinitializer_path
- "#{RAILS_ROOT}/config/preinitializer.rb"
- end
- end
-
- class Boot
- def run
- load_initializer
- Rails::Initializer.class_eval do
- def load_gems
- @bundler_loaded ||= Bundler.require :default, Rails.env
- end
- end
- Rails::Initializer.run(:set_load_path)
- end
- end
-
- class VendorBoot < Boot
- def load_initializer
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
- Rails::Initializer.run(:install_gem_spec_stubs)
- Rails::GemDependency.add_frozen_gem_path
- end
- end
-
- class GemBoot < Boot
- def load_initializer
- self.class.load_rubygems
- load_rails_gem
- require 'initializer'
- end
-
- def load_rails_gem
- if version = self.class.gem_version
- gem 'rails', version
- else
- gem 'rails'
- end
- rescue Gem::LoadError => load_error
- $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.)
- exit 1
- end
-
- class << self
- def rubygems_version
- Gem::RubyGemsVersion rescue nil
- end
-
- def gem_version
- if defined? RAILS_GEM_VERSION
- RAILS_GEM_VERSION
- elsif ENV.include?('RAILS_GEM_VERSION')
- ENV['RAILS_GEM_VERSION']
- else
- parse_gem_version(read_environment_rb)
- end
- end
-
- def load_rubygems
- min_version = '1.3.2'
- require 'rubygems'
- unless rubygems_version >= min_version
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
- exit 1
- end
-
- rescue LoadError
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
- exit 1
- end
-
- def parse_gem_version(text)
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
- end
-
- private
- def read_environment_rb
- File.read("#{RAILS_ROOT}/config/environment.rb")
- end
- end
- end
-end
-
-# All that for this:
-Rails.boot!
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+gemfile = File.expand_path('../../Gemfile', __FILE__)
+begin
+ ENV['BUNDLE_GEMFILE'] = gemfile
+ require 'bundler'
+ Bundler.setup
+rescue Bundler::GemNotFound => e
+ STDERR.puts e.message
+ STDERR.puts "Try running `bundle install`."
+ exit!
+end if File.exist?(gemfile)
View
@@ -0,0 +1,17 @@
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
View
@@ -1,40 +1,5 @@
-# Be sure to restart your server when you modify this file
+# Load the rails application
+require File.expand_path('../application', __FILE__)
-# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
-
-# Bootstrap the Rails environment, frameworks, and default configuration
-require File.join(File.dirname(__FILE__), 'boot')
-
-Rails::Initializer.run do |config|
- # Settings in config/environments/* take precedence over those specified here.
- # Application configuration should go into files in config/initializers
- # -- all .rb files in that directory are automatically loaded.
-
- # Add additional load paths for your own custom dirs
- config.load_paths += %W( #{RAILS_ROOT}/app/jobs )
-
- # Specify gems that this application depends on and have them installed with rake gems:install
- # config.gem "bj"
- # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
- # config.gem "sqlite3-ruby", :lib => "sqlite3"
- # config.gem "aws-s3", :lib => "aws/s3"
-
- # Only load the plugins named here, in the order given (default is alphabetical).
- # :all can be used as a placeholder for all plugins not explicitly named
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
-
- # Skip frameworks you're not going to use. To use Rails without a database,
- # you must remove the Active Record framework.
- # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
-
- # Activate observers that should always be running
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
-
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
- # Run "rake -D time" for a list of tasks for finding time zone names.
- config.time_zone = 'Eastern Time (US & Canada)'
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
- # config.i18n.default_locale = :de
-end
+# Initialize the rails application
+OaspCookieOverflow::Application.initialize!
Oops, something went wrong.

0 comments on commit 41352cf

Please sign in to comment.