crashlog 1.0.7 → 1.1.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/.travis.yml +19 -8
  2. data/Appraisals +25 -0
  3. data/Gemfile +4 -4
  4. data/Gemfile.lock +54 -13
  5. data/README.md +1 -1
  6. data/Rakefile +4 -0
  7. data/gemfiles/rails_2_3.gemfile +17 -0
  8. data/gemfiles/rails_2_3.gemfile.lock +111 -0
  9. data/gemfiles/rails_3_0.gemfile +17 -0
  10. data/gemfiles/rails_3_0.gemfile.lock +159 -0
  11. data/gemfiles/rails_3_1.gemfile +17 -0
  12. data/gemfiles/rails_3_1.gemfile.lock +169 -0
  13. data/gemfiles/rails_3_2.gemfile +17 -0
  14. data/gemfiles/rails_3_2.gemfile.lock +168 -0
  15. data/lib/crash_log.rb +2 -0
  16. data/lib/crash_log/payload.rb +2 -1
  17. data/lib/crash_log/rails/controller_methods.rb +98 -18
  18. data/lib/crash_log/rails/middleware/debug_exception_catcher.rb +6 -4
  19. data/lib/crash_log/railtie.rb +5 -4
  20. data/lib/crash_log/reporter.rb +4 -4
  21. data/lib/crash_log/sidekiq.rb +18 -0
  22. data/lib/crash_log/version.rb +1 -1
  23. data/spec/crash_log/initializer_spec.rb +39 -39
  24. data/spec/crash_log/payload_spec.rb +2 -0
  25. data/spec/dummy_rails_2/README +243 -0
  26. data/spec/dummy_rails_2/Rakefile +10 -0
  27. data/spec/dummy_rails_2/app/controllers/application_controller.rb +14 -0
  28. data/spec/dummy_rails_2/app/controllers/welcome_controller.rb +13 -0
  29. data/spec/dummy_rails_2/app/helpers/application_helper.rb +3 -0
  30. data/spec/dummy_rails_2/app/helpers/welcome_helper.rb +3 -0
  31. data/spec/dummy_rails_2/app/models/user.rb +2 -0
  32. data/spec/dummy_rails_2/config/boot.rb +114 -0
  33. data/spec/dummy_rails_2/config/environment.rb +41 -0
  34. data/spec/dummy_rails_2/config/environments/test.rb +28 -0
  35. data/spec/dummy_rails_2/config/initializers/backtrace_silencers.rb +7 -0
  36. data/spec/dummy_rails_2/config/initializers/cookie_verification_secret.rb +7 -0
  37. data/spec/{dummy → dummy_rails_2}/config/initializers/crashlog.rb +0 -0
  38. data/spec/dummy_rails_2/config/initializers/inflections.rb +10 -0
  39. data/spec/{dummy → dummy_rails_2}/config/initializers/mime_types.rb +0 -0
  40. data/spec/dummy_rails_2/config/initializers/new_rails_defaults.rb +13 -0
  41. data/spec/dummy_rails_2/config/initializers/session_store.rb +15 -0
  42. data/spec/dummy_rails_2/config/locales/en.yml +5 -0
  43. data/spec/dummy_rails_2/config/routes.rb +38 -0
  44. data/spec/dummy_rails_2/db/seeds.rb +7 -0
  45. data/spec/{dummy/app/mailers/.gitkeep → dummy_rails_2/log/development.log} +0 -0
  46. data/spec/{dummy/app/models/.gitkeep → dummy_rails_2/log/production.log} +0 -0
  47. data/spec/{dummy/lib/assets/.gitkeep → dummy_rails_2/log/server.log} +0 -0
  48. data/spec/dummy_rails_3/.gitignore +4 -0
  49. data/spec/dummy_rails_3/Gemfile +31 -0
  50. data/spec/dummy_rails_3/README +256 -0
  51. data/spec/dummy_rails_3/Rakefile +7 -0
  52. data/spec/dummy_rails_3/app/controllers/application_controller.rb +7 -0
  53. data/spec/dummy_rails_3/app/controllers/welcome_controller.rb +14 -0
  54. data/spec/{dummy → dummy_rails_3}/app/helpers/application_helper.rb +0 -0
  55. data/spec/dummy_rails_3/app/models/user.rb +3 -0
  56. data/spec/dummy_rails_3/app/views/layouts/application.html.erb +14 -0
  57. data/spec/{dummy → dummy_rails_3}/config.ru +0 -0
  58. data/spec/dummy_rails_3/config/application.rb +52 -0
  59. data/spec/dummy_rails_3/config/boot.rb +6 -0
  60. data/spec/{dummy → dummy_rails_3}/config/environment.rb +0 -0
  61. data/spec/dummy_rails_3/config/environments/development.rb +26 -0
  62. data/spec/dummy_rails_3/config/environments/production.rb +49 -0
  63. data/spec/dummy_rails_3/config/environments/test.rb +35 -0
  64. data/spec/{dummy → dummy_rails_3}/config/initializers/backtrace_silencers.rb +0 -0
  65. data/spec/dummy_rails_3/config/initializers/crashlog.rb +8 -0
  66. data/spec/dummy_rails_3/config/initializers/inflections.rb +10 -0
  67. data/spec/dummy_rails_3/config/initializers/mime_types.rb +5 -0
  68. data/spec/dummy_rails_3/config/initializers/secret_token.rb +7 -0
  69. data/spec/{dummy → dummy_rails_3}/config/initializers/session_store.rb +0 -0
  70. data/spec/dummy_rails_3/config/locales/en.yml +5 -0
  71. data/spec/dummy_rails_3/config/routes.rb +5 -0
  72. data/spec/dummy_rails_3/db/seeds.rb +7 -0
  73. data/spec/{dummy → dummy_rails_3_plus}/README.rdoc +0 -0
  74. data/spec/{dummy → dummy_rails_3_plus}/Rakefile +0 -0
  75. data/spec/{dummy → dummy_rails_3_plus}/app/assets/javascripts/application.js +0 -0
  76. data/spec/{dummy → dummy_rails_3_plus}/app/assets/stylesheets/application.css +0 -0
  77. data/spec/dummy_rails_3_plus/app/controllers/application_controller.rb +7 -0
  78. data/spec/{dummy → dummy_rails_3_plus}/app/controllers/break_controller.rb +0 -0
  79. data/spec/dummy_rails_3_plus/app/controllers/welcome_controller.rb +13 -0
  80. data/spec/dummy_rails_3_plus/app/helpers/application_helper.rb +2 -0
  81. data/spec/{dummy/log → dummy_rails_3_plus/app/mailers}/.gitkeep +0 -0
  82. data/spec/{dummy/public/favicon.ico → dummy_rails_3_plus/app/models/.gitkeep} +0 -0
  83. data/spec/{dummy → dummy_rails_3_plus}/app/models/current_user.rb +0 -0
  84. data/spec/{dummy → dummy_rails_3_plus}/app/views/layouts/application.html.erb +0 -0
  85. data/spec/dummy_rails_3_plus/config.ru +4 -0
  86. data/spec/{dummy → dummy_rails_3_plus}/config/application.rb +3 -3
  87. data/spec/{dummy → dummy_rails_3_plus}/config/boot.rb +0 -0
  88. data/spec/dummy_rails_3_plus/config/environment.rb +5 -0
  89. data/spec/{dummy → dummy_rails_3_plus}/config/environments/development.rb +0 -0
  90. data/spec/{dummy → dummy_rails_3_plus}/config/environments/production.rb +0 -0
  91. data/spec/{dummy → dummy_rails_3_plus}/config/environments/test.rb +2 -2
  92. data/spec/dummy_rails_3_plus/config/initializers/backtrace_silencers.rb +7 -0
  93. data/spec/dummy_rails_3_plus/config/initializers/crashlog.rb +7 -0
  94. data/spec/{dummy → dummy_rails_3_plus}/config/initializers/inflections.rb +0 -0
  95. data/spec/dummy_rails_3_plus/config/initializers/mime_types.rb +5 -0
  96. data/spec/{dummy → dummy_rails_3_plus}/config/initializers/secret_token.rb +0 -0
  97. data/spec/dummy_rails_3_plus/config/initializers/session_store.rb +8 -0
  98. data/spec/{dummy → dummy_rails_3_plus}/config/initializers/wrap_parameters.rb +0 -0
  99. data/spec/dummy_rails_3_plus/config/routes.rb +5 -0
  100. data/spec/dummy_rails_3_plus/lib/assets/.gitkeep +0 -0
  101. data/spec/dummy_rails_3_plus/log/.gitkeep +0 -0
  102. data/spec/dummy_rails_3_plus/log/development.log +13209 -0
  103. data/spec/{dummy → dummy_rails_3_plus}/public/404.html +0 -0
  104. data/spec/{dummy → dummy_rails_3_plus}/public/422.html +0 -0
  105. data/spec/{dummy → dummy_rails_3_plus}/public/500.html +0 -0
  106. data/spec/dummy_rails_3_plus/public/favicon.ico +0 -0
  107. data/spec/{dummy → dummy_rails_3_plus}/script/rails +0 -0
  108. data/spec/rails/action_controller_spec.rb +85 -0
  109. data/spec/rails/rails_2_controller_spec.rb +87 -0
  110. data/spec/rails_spec_helper.rb +42 -0
  111. data/spec/requests/rails_controller_rescue_spec.rb +6 -6
  112. data/spec/spec_helper.rb +0 -4
  113. metadata +204 -87
  114. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  115. data/spec/dummy/config/database.yml +0 -44
  116. data/spec/dummy/config/routes.rb +0 -7
@@ -0,0 +1,10 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5
+
6
+ require 'rake'
7
+ require 'rake/testtask'
8
+ require 'rake/rdoctask'
9
+
10
+ require 'tasks/rails'
@@ -0,0 +1,14 @@
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
+ class ApplicationController < ActionController::Base
5
+ # helper :all # include all helpers, all the time
6
+ # protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
+
8
+ # Scrub sensitive parameters from your log
9
+ filter_parameter_logging :password
10
+
11
+ def current_user
12
+ User.new({:id => 1, :email => 'user@example.com', :full_name => "Johnny Quid"})
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ class WelcomeController < ApplicationController
2
+
3
+ layout :application
4
+
5
+ def index
6
+ render :text => "Welcome"
7
+ end
8
+
9
+ def broken
10
+ @projects = []
11
+ raise StandardError, "Broken route"
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,3 @@
1
+ module WelcomeHelper
2
+
3
+ end
@@ -0,0 +1,2 @@
1
+ class User < OpenStruct
2
+ end
@@ -0,0 +1,114 @@
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
+ if load_error.message =~ /Could not find RubyGem rails/
66
+ 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.)
67
+ exit 1
68
+ else
69
+ raise
70
+ end
71
+ end
72
+
73
+ class << self
74
+ def rubygems_version
75
+ Gem::RubyGemsVersion rescue nil
76
+ end
77
+
78
+ def gem_version
79
+ if defined? RAILS_GEM_VERSION
80
+ RAILS_GEM_VERSION
81
+ elsif ENV.include?('RAILS_GEM_VERSION')
82
+ ENV['RAILS_GEM_VERSION']
83
+ else
84
+ parse_gem_version(read_environment_rb)
85
+ end
86
+ end
87
+
88
+ def load_rubygems
89
+ min_version = '1.3.2'
90
+ require 'rubygems'
91
+ unless rubygems_version >= min_version
92
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
93
+ exit 1
94
+ end
95
+
96
+ rescue LoadError
97
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
98
+ exit 1
99
+ end
100
+
101
+ def parse_gem_version(text)
102
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
103
+ end
104
+
105
+ private
106
+ def read_environment_rb
107
+ File.read("#{RAILS_ROOT}/config/environment.rb")
108
+ end
109
+ end
110
+ end
111
+ end
112
+
113
+ # All that for this:
114
+ Rails.boot!
@@ -0,0 +1,41 @@
1
+ # Be sure to restart your server when you modify this file
2
+
3
+ # Specifies gem version of Rails to use when vendor/rails is not present
4
+ RAILS_GEM_VERSION = '2.3.14' unless defined? RAILS_GEM_VERSION
5
+ RAILS_ENV='test'
6
+ # Bootstrap the Rails environment, frameworks, and default configuration
7
+ require File.join(File.dirname(__FILE__), 'boot')
8
+
9
+ Rails::Initializer.run do |config|
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Add additional load paths for your own custom dirs
15
+ # config.autoload_paths += %W( #{RAILS_ROOT}/extras )
16
+
17
+ # Specify gems that this application depends on and have them installed with rake gems:install
18
+ # config.gem "bj"
19
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
20
+ # config.gem "sqlite3-ruby", :lib => "sqlite3"
21
+ # config.gem "aws-s3", :lib => "aws/s3"
22
+
23
+ # Only load the plugins named here, in the order given (default is alphabetical).
24
+ # :all can be used as a placeholder for all plugins not explicitly named
25
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
26
+
27
+ # Skip frameworks you're not going to use. To use Rails without a database,
28
+ # you must remove the Active Record framework.
29
+ config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
30
+
31
+ # Activate observers that should always be running
32
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
33
+
34
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
35
+ # Run "rake -D time" for a list of tasks for finding time zone names.
36
+ config.time_zone = 'UTC'
37
+
38
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
39
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
40
+ # config.i18n.default_locale = :de
41
+ end
@@ -0,0 +1,28 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+ config.cache_classes = true
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.action_controller.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+ config.action_view.cache_template_loading = true
16
+
17
+ # Disable request forgery protection in test environment
18
+ config.action_controller.allow_forgery_protection = false
19
+
20
+ # Tell Action Mailer not to deliver emails to the real world.
21
+ # The :test delivery method accumulates sent emails in the
22
+ # ActionMailer::Base.deliveries array.
23
+ # config.action_mailer.delivery_method = :test
24
+
25
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
26
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
27
+ # like if you have constraints or database-specific column types
28
+ # config.active_record.schema_format = :sql
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ ActionController::Base.cookie_verifier_secret = '2be366aa46b6f69e3f02e198a5c71c75aa52d501d0f8d403eb4f93d41fe8481c02a00589674691673f706ebd5db1ea629927c80a763344a6279e376a4c3c2751';
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,13 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # These settings change the behavior of Rails 2 apps and will be defaults
4
+ # for Rails 3. You can remove this initializer when Rails 3 is released.
5
+
6
+ ActionController::Routing.generate_best_match = false
7
+
8
+ # Use ISO 8601 format for JSON serialized times and dates.
9
+ ActiveSupport.use_standard_json_time_format = true
10
+
11
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
12
+ # if you're including raw json in an HTML page.
13
+ ActiveSupport.escape_html_entities_in_json = false
@@ -0,0 +1,15 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying cookie session data integrity.
4
+ # If you change this key, all old sessions will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ ActionController::Base.session = {
8
+ :key => '_dummy_session',
9
+ :secret => 'f8fa2bdad5cacb48464bca0853feb6923ed070084fb65e1838b72f6ef7c3dc2e3a56a26585a322d202d7c4b99e6a18ebf22a14b5c4ac31a815486b9c201d760e'
10
+ }
11
+
12
+ # Use the database for sessions instead of the cookie-based default,
13
+ # which shouldn't be used to store highly confidential information
14
+ # (create the session table with "rake db:sessions:create")
15
+ # ActionController::Base.session_store = :active_record_store
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,38 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.connect 'broken', :controller => 'welcome', :action => 'broken'
3
+
4
+ # Sample of named route:
5
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
6
+ # This route can be invoked with purchase_url(:id => product.id)
7
+
8
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
9
+ # map.resources :products
10
+
11
+ # Sample resource route with options:
12
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
13
+
14
+ # Sample resource route with sub-resources:
15
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
16
+
17
+ # Sample resource route with more complex sub-resources
18
+ # map.resources :products do |products|
19
+ # products.resources :comments
20
+ # products.resources :sales, :collection => { :recent => :get }
21
+ # end
22
+
23
+ # Sample resource route within a namespace:
24
+ # map.namespace :admin do |admin|
25
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
26
+ # admin.resources :products
27
+ # end
28
+
29
+ map.root :controller => "welcome"
30
+
31
+ # See how all your routes lay out with "rake routes"
32
+
33
+ # Install the default routes as the lowest priority.
34
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
35
+ # consider removing or commenting them out if you're using named routes and resources.
36
+ # map.connect ':controller/:action/:id'
37
+ # map.connect ':controller/:action/:id.:format'
38
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
+ # Major.create(:name => 'Daley', :city => cities.first)
@@ -0,0 +1,4 @@
1
+ .bundle
2
+ db/*.sqlite3
3
+ log/*.log
4
+ tmp/
@@ -0,0 +1,31 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '3.0.17'
4
+
5
+ # Bundle edge Rails instead:
6
+ # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
+
8
+ gem 'sqlite3'
9
+
10
+ # Use unicorn as the web server
11
+ # gem 'unicorn'
12
+
13
+ # Deploy with Capistrano
14
+ # gem 'capistrano'
15
+
16
+ # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
17
+ # gem 'ruby-debug'
18
+ # gem 'ruby-debug19', :require => 'ruby-debug'
19
+
20
+ # Bundle the extra gems:
21
+ # gem 'bj'
22
+ # gem 'nokogiri'
23
+ # gem 'sqlite3-ruby', :require => 'sqlite3'
24
+ # gem 'aws-s3', :require => 'aws/s3'
25
+
26
+ # Bundle gems for the local environment. Make sure to
27
+ # put test-only gems in this group so their generators
28
+ # and rake tasks are available in development mode:
29
+ # group :development, :test do
30
+ # gem 'webrat'
31
+ # end
@@ -0,0 +1,256 @@
1
+ == Welcome to Rails
2
+
3
+ Rails is a web-application framework that includes everything needed to create
4
+ database-backed web applications according to the Model-View-Control pattern.
5
+
6
+ This pattern splits the view (also called the presentation) into "dumb"
7
+ templates that are primarily responsible for inserting pre-built data in between
8
+ HTML tags. The model contains the "smart" domain objects (such as Account,
9
+ Product, Person, Post) that holds all the business logic and knows how to
10
+ persist themselves to a database. The controller handles the incoming requests
11
+ (such as Save New Account, Update Product, Show Post) by manipulating the model
12
+ and directing data to the view.
13
+
14
+ In Rails, the model is handled by what's called an object-relational mapping
15
+ layer entitled Active Record. This layer allows you to present the data from
16
+ database rows as objects and embellish these data objects with business logic
17
+ methods. You can read more about Active Record in
18
+ link:files/vendor/rails/activerecord/README.html.
19
+
20
+ The controller and view are handled by the Action Pack, which handles both
21
+ layers by its two parts: Action View and Action Controller. These two layers
22
+ are bundled in a single package due to their heavy interdependence. This is
23
+ unlike the relationship between the Active Record and Action Pack that is much
24
+ more separate. Each of these packages can be used independently outside of
25
+ Rails. You can read more about Action Pack in
26
+ link:files/vendor/rails/actionpack/README.html.
27
+
28
+
29
+ == Getting Started
30
+
31
+ 1. At the command prompt, create a new Rails application:
32
+ <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
33
+
34
+ 2. Change directory to <tt>myapp</tt> and start the web server:
35
+ <tt>cd myapp; rails server</tt> (run with --help for options)
36
+
37
+ 3. Go to http://localhost:3000/ and you'll see:
38
+ "Welcome aboard: You're riding Ruby on Rails!"
39
+
40
+ 4. Follow the guidelines to start developing your application. You can find
41
+ the following resources handy:
42
+
43
+ * The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
44
+ * Ruby on Rails Tutorial Book: http://www.railstutorial.org/
45
+
46
+
47
+ == Debugging Rails
48
+
49
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
50
+ will help you debug it and get it back on the rails.
51
+
52
+ First area to check is the application log files. Have "tail -f" commands
53
+ running on the server.log and development.log. Rails will automatically display
54
+ debugging and runtime information to these files. Debugging info will also be
55
+ shown in the browser on requests from 127.0.0.1.
56
+
57
+ You can also log your own messages directly into the log file from your code
58
+ using the Ruby logger class from inside your controllers. Example:
59
+
60
+ class WeblogController < ActionController::Base
61
+ def destroy
62
+ @weblog = Weblog.find(params[:id])
63
+ @weblog.destroy
64
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
65
+ end
66
+ end
67
+
68
+ The result will be a message in your log file along the lines of:
69
+
70
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
71
+
72
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
73
+
74
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
75
+ several books available online as well:
76
+
77
+ * Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
78
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
79
+
80
+ These two books will bring you up to speed on the Ruby language and also on
81
+ programming in general.
82
+
83
+
84
+ == Debugger
85
+
86
+ Debugger support is available through the debugger command when you start your
87
+ Mongrel or WEBrick server with --debugger. This means that you can break out of
88
+ execution at any point in the code, investigate and change the model, and then,
89
+ resume execution! You need to install ruby-debug to run the server in debugging
90
+ mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
91
+
92
+ class WeblogController < ActionController::Base
93
+ def index
94
+ @posts = Post.find(:all)
95
+ debugger
96
+ end
97
+ end
98
+
99
+ So the controller will accept the action, run the first line, then present you
100
+ with a IRB prompt in the server window. Here you can do things like:
101
+
102
+ >> @posts.inspect
103
+ => "[#<Post:0x14a6be8
104
+ @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
105
+ #<Post:0x14a6620
106
+ @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
107
+ >> @posts.first.title = "hello from a debugger"
108
+ => "hello from a debugger"
109
+
110
+ ...and even better, you can examine how your runtime objects actually work:
111
+
112
+ >> f = @posts.first
113
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
114
+ >> f.
115
+ Display all 152 possibilities? (y or n)
116
+
117
+ Finally, when you're ready to resume execution, you can enter "cont".
118
+
119
+
120
+ == Console
121
+
122
+ The console is a Ruby shell, which allows you to interact with your
123
+ application's domain model. Here you'll have all parts of the application
124
+ configured, just like it is when the application is running. You can inspect
125
+ domain models, change values, and save to the database. Starting the script
126
+ without arguments will launch it in the development environment.
127
+
128
+ To start the console, run <tt>rails console</tt> from the application
129
+ directory.
130
+
131
+ Options:
132
+
133
+ * Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
134
+ made to the database.
135
+ * Passing an environment name as an argument will load the corresponding
136
+ environment. Example: <tt>rails console production</tt>.
137
+
138
+ To reload your controllers and models after launching the console run
139
+ <tt>reload!</tt>
140
+
141
+ More information about irb can be found at:
142
+ link:http://www.rubycentral.com/pickaxe/irb.html
143
+
144
+
145
+ == dbconsole
146
+
147
+ You can go to the command line of your database directly through <tt>rails
148
+ dbconsole</tt>. You would be connected to the database with the credentials
149
+ defined in database.yml. Starting the script without arguments will connect you
150
+ to the development database. Passing an argument will connect you to a different
151
+ database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
152
+ PostgreSQL and SQLite 3.
153
+
154
+ == Description of Contents
155
+
156
+ The default directory structure of a generated Ruby on Rails application:
157
+
158
+ |-- app
159
+ | |-- controllers
160
+ | |-- helpers
161
+ | |-- mailers
162
+ | |-- models
163
+ | `-- views
164
+ | `-- layouts
165
+ |-- config
166
+ | |-- environments
167
+ | |-- initializers
168
+ | `-- locales
169
+ |-- db
170
+ |-- doc
171
+ |-- lib
172
+ | `-- tasks
173
+ |-- log
174
+ |-- public
175
+ | |-- images
176
+ | |-- javascripts
177
+ | `-- stylesheets
178
+ |-- script
179
+ |-- test
180
+ | |-- fixtures
181
+ | |-- functional
182
+ | |-- integration
183
+ | |-- performance
184
+ | `-- unit
185
+ |-- tmp
186
+ | |-- cache
187
+ | |-- pids
188
+ | |-- sessions
189
+ | `-- sockets
190
+ `-- vendor
191
+ `-- plugins
192
+
193
+ app
194
+ Holds all the code that's specific to this particular application.
195
+
196
+ app/controllers
197
+ Holds controllers that should be named like weblogs_controller.rb for
198
+ automated URL mapping. All controllers should descend from
199
+ ApplicationController which itself descends from ActionController::Base.
200
+
201
+ app/models
202
+ Holds models that should be named like post.rb. Models descend from
203
+ ActiveRecord::Base by default.
204
+
205
+ app/views
206
+ Holds the template files for the view that should be named like
207
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
208
+ eRuby syntax by default.
209
+
210
+ app/views/layouts
211
+ Holds the template files for layouts to be used with views. This models the
212
+ common header/footer method of wrapping views. In your views, define a layout
213
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
214
+ Inside default.html.erb, call <% yield %> to render the view using this
215
+ layout.
216
+
217
+ app/helpers
218
+ Holds view helpers that should be named like weblogs_helper.rb. These are
219
+ generated for you automatically when using generators for controllers.
220
+ Helpers can be used to wrap functionality for your views into methods.
221
+
222
+ config
223
+ Configuration files for the Rails environment, the routing map, the database,
224
+ and other dependencies.
225
+
226
+ db
227
+ Contains the database schema in schema.rb. db/migrate contains all the
228
+ sequence of Migrations for your schema.
229
+
230
+ doc
231
+ This directory is where your application documentation will be stored when
232
+ generated using <tt>rake doc:app</tt>
233
+
234
+ lib
235
+ Application specific libraries. Basically, any kind of custom code that
236
+ doesn't belong under controllers, models, or helpers. This directory is in
237
+ the load path.
238
+
239
+ public
240
+ The directory available for the web server. Contains subdirectories for
241
+ images, stylesheets, and javascripts. Also contains the dispatchers and the
242
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
243
+ server.
244
+
245
+ script
246
+ Helper scripts for automation and generation.
247
+
248
+ test
249
+ Unit and functional tests along with fixtures. When using the rails generate
250
+ command, template test files will be generated for you and placed in this
251
+ directory.
252
+
253
+ vendor
254
+ External libraries that the application depends on. Also includes the plugins
255
+ subdirectory. If the app has frozen rails, those gems also go here, under
256
+ vendor/rails/. This directory is in the load path.