active_reload 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. data/.gitignore +10 -0
  2. data/README.md +157 -0
  3. data/Rakefile +28 -1
  4. data/active_reload.gemspec +1 -0
  5. data/lib/active_reload.rb +31 -3
  6. data/lib/active_reload/version.rb +1 -1
  7. data/test/dummy309/Gemfile +32 -0
  8. data/test/dummy309/README +256 -0
  9. data/test/dummy309/Rakefile +7 -0
  10. data/test/dummy309/app/controllers/application_controller.rb +3 -0
  11. data/test/dummy309/app/controllers/empty_controller.rb +5 -0
  12. data/test/dummy309/app/views/layouts/application.html.erb +14 -0
  13. data/test/dummy309/config.ru +4 -0
  14. data/test/dummy309/config/application.rb +42 -0
  15. data/test/dummy309/config/boot.rb +11 -0
  16. data/test/dummy309/config/database.yml +22 -0
  17. data/test/dummy309/config/environment.rb +5 -0
  18. data/test/dummy309/config/environments/development.rb +29 -0
  19. data/test/dummy309/config/environments/production.rb +49 -0
  20. data/test/dummy309/config/environments/test.rb +35 -0
  21. data/test/dummy309/config/initializers/backtrace_silencers.rb +7 -0
  22. data/test/dummy309/config/initializers/inflections.rb +10 -0
  23. data/test/dummy309/config/initializers/mime_types.rb +5 -0
  24. data/test/dummy309/config/initializers/secret_token.rb +7 -0
  25. data/test/dummy309/config/initializers/session_store.rb +8 -0
  26. data/test/dummy309/config/locales/en.yml +5 -0
  27. data/test/dummy309/config/routes.rb +61 -0
  28. data/test/dummy309/db/seeds.rb +7 -0
  29. data/test/dummy309/doc/README_FOR_APP +2 -0
  30. data/test/dummy309/lib/tasks/.gitkeep +0 -0
  31. data/test/dummy309/public/404.html +26 -0
  32. data/test/dummy309/public/422.html +26 -0
  33. data/test/dummy309/public/500.html +26 -0
  34. data/test/dummy309/public/favicon.ico +0 -0
  35. data/test/dummy309/public/images/rails.png +0 -0
  36. data/test/dummy309/public/index.html +239 -0
  37. data/test/dummy309/public/javascripts/application.js +2 -0
  38. data/test/dummy309/public/javascripts/controls.js +965 -0
  39. data/test/dummy309/public/javascripts/dragdrop.js +974 -0
  40. data/test/dummy309/public/javascripts/effects.js +1123 -0
  41. data/test/dummy309/public/javascripts/prototype.js +6001 -0
  42. data/test/dummy309/public/javascripts/rails.js +191 -0
  43. data/test/dummy309/public/robots.txt +5 -0
  44. data/test/dummy309/public/stylesheets/.gitkeep +0 -0
  45. data/test/dummy309/script/rails +6 -0
  46. data/test/dummy309/test/performance/browsing_test.rb +9 -0
  47. data/test/dummy309/test/test_helper.rb +13 -0
  48. data/test/dummy309/vendor/plugins/.gitkeep +0 -0
  49. data/test/dummy310rc4/.gitignore +5 -0
  50. data/test/dummy310rc4/Gemfile +12 -0
  51. data/test/dummy310rc4/README +261 -0
  52. data/test/dummy310rc4/Rakefile +7 -0
  53. data/test/dummy310rc4/app/assets/images/rails.png +0 -0
  54. data/test/dummy310rc4/app/assets/javascripts/application.js +9 -0
  55. data/test/dummy310rc4/app/assets/stylesheets/application.css +7 -0
  56. data/test/dummy310rc4/app/controllers/application_controller.rb +3 -0
  57. data/test/dummy310rc4/app/helpers/application_helper.rb +2 -0
  58. data/test/dummy310rc4/app/mailers/.gitkeep +0 -0
  59. data/test/dummy310rc4/app/models/.gitkeep +0 -0
  60. data/test/dummy310rc4/app/views/layouts/application.html.erb +14 -0
  61. data/test/dummy310rc4/config.ru +4 -0
  62. data/test/dummy310rc4/config/application.rb +42 -0
  63. data/test/dummy310rc4/config/boot.rb +6 -0
  64. data/test/dummy310rc4/config/database.yml +25 -0
  65. data/test/dummy310rc4/config/environment.rb +5 -0
  66. data/test/dummy310rc4/config/environments/development.rb +45 -0
  67. data/test/dummy310rc4/config/environments/production.rb +54 -0
  68. data/test/dummy310rc4/config/environments/test.rb +39 -0
  69. data/test/dummy310rc4/config/initializers/backtrace_silencers.rb +7 -0
  70. data/test/dummy310rc4/config/initializers/inflections.rb +10 -0
  71. data/test/dummy310rc4/config/initializers/mime_types.rb +5 -0
  72. data/test/dummy310rc4/config/initializers/secret_token.rb +7 -0
  73. data/test/dummy310rc4/config/initializers/session_store.rb +8 -0
  74. data/test/dummy310rc4/config/initializers/wrap_parameters.rb +12 -0
  75. data/test/dummy310rc4/config/locales/en.yml +5 -0
  76. data/test/dummy310rc4/config/routes.rb +61 -0
  77. data/test/dummy310rc4/db/seeds.rb +7 -0
  78. data/test/dummy310rc4/doc/README_FOR_APP +2 -0
  79. data/test/dummy310rc4/lib/tasks/.gitkeep +0 -0
  80. data/test/dummy310rc4/log/.gitkeep +0 -0
  81. data/test/dummy310rc4/public/404.html +26 -0
  82. data/test/dummy310rc4/public/422.html +26 -0
  83. data/test/dummy310rc4/public/500.html +26 -0
  84. data/test/dummy310rc4/public/favicon.ico +0 -0
  85. data/test/dummy310rc4/public/index.html +241 -0
  86. data/test/dummy310rc4/public/robots.txt +5 -0
  87. data/test/dummy310rc4/script/rails +6 -0
  88. data/test/dummy310rc4/test/fixtures/.gitkeep +0 -0
  89. data/test/dummy310rc4/test/functional/.gitkeep +0 -0
  90. data/test/dummy310rc4/test/integration/.gitkeep +0 -0
  91. data/test/dummy310rc4/test/performance/browsing_test.rb +12 -0
  92. data/test/dummy310rc4/test/test_helper.rb +13 -0
  93. data/test/dummy310rc4/test/unit/.gitkeep +0 -0
  94. data/test/dummy310rc4/vendor/assets/stylesheets/.gitkeep +0 -0
  95. data/test/dummy310rc4/vendor/plugins/.gitkeep +0 -0
  96. data/test/support/defined_middleware.rb +16 -0
  97. data/test/unit/reload_test.rb +119 -0
  98. metadata +112 -10
  99. data/README.textile +0 -58
data/.gitignore CHANGED
@@ -3,3 +3,13 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  nbproject
6
+
7
+
8
+ test/dummy*/.bundle
9
+ test/dummy*/db/*.sqlite3
10
+ test/dummy*/log/*.log
11
+ test/dummy*/tmp/
12
+ test/dummy*/vendor/bundle/
13
+
14
+ test/dummy310rc4/app/controllers/root_controller.rb
15
+ test/dummy309/app/controllers/root_controller.rb
data/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # Active Reload
2
+ ## The only Rails boost tool that doesn't try to be too smart.
3
+
4
+ <a href='http://www.pledgie.com/campaigns/15547'><img alt='Donate Active Reload at www.pledgie.com' src='http://pledgie.com/campaigns/15547.png?skin_name=chrome' border='0' /></a>
5
+
6
+ Active Reload is a gem that changes a little when Rails code reloading is executed.
7
+ Normally Rails "forgets" your code after every request in development mode and loads again necessary
8
+ files during the request. If your application is big this can take lot of time especially on "dashboard" page
9
+ that uses lot of different classes.
10
+
11
+ However this constant reloading is not always necessary. This gem changes it so it occurs
12
+ before request and only when file was changed or added. It won't make reloading your app
13
+ faster but it will skip reloading when nothing changed and that saved second can really sum
14
+ up to a big value. It means that after change first request in development mode will reload the code
15
+ and take as much time as it takes without this gem but subsequent request will be faster until next
16
+ changes due to lack of code reloading.
17
+
18
+ ## Y U NO BELIEVE ?
19
+
20
+ Watch these videos for comparison:
21
+
22
+ ### 2 simultaneous movies:
23
+
24
+ http://youtubedoubler.com/1fts
25
+
26
+ ### Spree in development mode without Active Reload
27
+ <a href='http://www.youtube.com/watch?v=KIOV5Me-83M'><img alt='Spree in development mode' src='http://img.youtube.com/vi/KIOV5Me-83M/0.jpg' border='0' /></a>
28
+
29
+ ### Spree in development and Active Reload enabled
30
+
31
+ <a href='http://www.youtube.com/watch?v=HelS-mVnfI4'><img alt='Spree in development mode with enabled Active Reload' src='http://img.youtube.com/vi/HelS-mVnfI4/0.jpg' border='0' /></a>
32
+
33
+ ## Installation
34
+
35
+ Simply add Active Reload to your Gemfile and bundle it up:
36
+
37
+ ```ruby
38
+ gem 'active_reload'
39
+ ```
40
+
41
+ ## Compatibility
42
+
43
+ It was hand tested only with Rails 3.0.9 but should work without any problem on any `3.0.*` and `3.1.*` Rails version. I'm in the middle of writing automatic tests for it.
44
+
45
+ It should work with any ruby compatible with `1.9.2` (ex. JRuby). Expect `1.8.7` support soon.
46
+
47
+ ## Notifications
48
+
49
+ You can subscribe to two notifications provided by this gem.
50
+
51
+ `active_reload.set_clear_dependencies_hook_replaced` event is triggered when the gem changes original rails hook for code reloading.
52
+
53
+ ```ruby
54
+ ActiveSupport::Notifications.subscribe("active_reload.set_clear_dependencies_hook_replaced") do |*args|
55
+ event = ActiveSupport::Notifications::Event.new(*args)
56
+ msg = event.name
57
+ # Ubuntu: https://github.com/splattael/libnotify, Example: Libnotify.show(:body => msg, :summary => Rails.application.class.name, :timeout => 2.5, :append => true)
58
+ # Macos: http://segment7.net/projects/ruby/growl/
59
+ puts Rails.logger.warn(" --- #{msg} --- ")
60
+ end
61
+ ```
62
+
63
+ `active_support.dependencies.clear` event is triggered when code reloading is triggered by this gem.
64
+
65
+ ```ruby
66
+ ActiveSupport::Notifications.subscribe("active_support.dependencies.clear") do |*args|
67
+ msg = "Code reloaded!"
68
+ # Ubuntu: https://github.com/splattael/libnotify, Example: Libnotify.show(:body => msg, :summary => Rails.application.class.name, :timeout => 2.5, :append => true)
69
+ # Macos: http://segment7.net/projects/ruby/growl/
70
+ puts Rails.logger.info(" --- #{msg} --- ")
71
+ end
72
+ ```
73
+
74
+ ## Links
75
+
76
+ * http://blog.robert.pankowecki.pl/2011/06/faster-rails-development-part-2.html
77
+ * http://blog.robert.pankowecki.pl/2011/05/get-faster-rails-development.html
78
+
79
+ ## Do you want to reproduce the video experiment ?
80
+
81
+ The tested spree version was: https://github.com/spree/spree/tree/42795d91d3680394ef70126e6660cac3da81e8a9
82
+
83
+ It was installed in sandbox mode:
84
+
85
+ ```bash
86
+ git clone git://github.com/spree/spree.git spree
87
+ cd spree
88
+ git checkout 42795d91d3680394ef70126e6660cac3da81e8a9
89
+ bundle install
90
+ rake sandbox
91
+ cd sandbox
92
+ # Edit Gemfile to add or remove active_reload support
93
+ rails server
94
+ ```
95
+
96
+ Here is the ruby script that walks through the site using capybara:
97
+
98
+ ```ruby
99
+ require 'bbq/test' # https://github.com/drugpl/bbq
100
+ require 'benchmark'
101
+
102
+ shop = ["Ruby on Rails", "Apache", "Clothing", "Bags", "Mugs"]
103
+ admin = [
104
+ "Overview",
105
+ "Orders",
106
+ "Next",
107
+ "Products",
108
+ "Option Types",
109
+ "Properties",
110
+ "Prototypes",
111
+ "Product Groups",
112
+ "Reports",
113
+ "Sales Total",
114
+ "Configuration",
115
+ "General Settings",
116
+ "Mail Methods",
117
+ "Tax Categories",
118
+ "Zones",
119
+ "States",
120
+ "Payment Methods",
121
+ "Taxonomies",
122
+ "Shipping Methods",
123
+ "Inventory Settings",
124
+ "Analytics Trackers",
125
+ "Complete List",
126
+ "Users",
127
+ "Promotions"
128
+ ]
129
+
130
+ user = Bbq::TestUser.new(:driver => :selenium, :session => :default)
131
+ user.visit("/")
132
+
133
+ Benchmark.measure do
134
+
135
+ shop.each do |link|
136
+ user.click_on(link)
137
+ end
138
+
139
+ user.visit("/admin")
140
+ user.fill_in("Email", :with => "spree@example.com")
141
+ user.fill_in("Password", :with => "spree@example.com")
142
+ user.click_button("Log In")
143
+
144
+ admin.each do |link|
145
+ user.click_on(link)
146
+ end
147
+
148
+ FileUtils.touch( Rails.root.join("app/controllers/application_controller.rb") )
149
+
150
+ admin.first(5).each do |link|
151
+ user.click_on(link)
152
+ end
153
+
154
+ user.click_on "Logout"
155
+
156
+ end
157
+ ```
data/Rakefile CHANGED
@@ -1 +1,28 @@
1
- require 'bundler/gem_tasks'
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ Bundler::GemHelper.install_tasks
9
+ require 'rdoc/task'
10
+
11
+ RDoc::Task.new do |rdoc|
12
+ rdoc.rdoc_dir = 'rdoc'
13
+ rdoc.title = 'Bbq'
14
+ rdoc.options << '--line-numbers' << '--inline-source'
15
+ rdoc.rdoc_files.include('README.rdoc')
16
+ rdoc.rdoc_files.include('lib/**/*.rb')
17
+ end
18
+
19
+ require 'rake/testtask'
20
+
21
+ Rake::TestTask.new(:test) do |t|
22
+ t.libs << 'lib'
23
+ t.libs << 'test'
24
+ t.pattern = 'test/unit/*_test.rb' # Don't load test/dummy/test
25
+ t.verbose = false
26
+ end
27
+
28
+ task :default => :test
@@ -19,4 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_development_dependency "rake"
22
+ s.add_development_dependency "bbq"
22
23
  end
data/lib/active_reload.rb CHANGED
@@ -9,7 +9,23 @@ module ActiveReload
9
9
  end # Railtie
10
10
 
11
11
  def self.replace?
12
- !Rails.application.config.cache_classes && replace_proc?(ActionDispatch::Callbacks.instance_variable_get(:@_call_callbacks).last)
12
+ !Rails.application.config.cache_classes && replace_proc?(proc_collection.last)
13
+ end
14
+
15
+ def self.proc_collection
16
+ if rails31?
17
+ proc_source._cleanup_callbacks
18
+ else
19
+ proc_source._call_callbacks
20
+ end
21
+ end
22
+
23
+ def self.proc_source
24
+ if rails31?
25
+ ActionDispatch::Reloader
26
+ else
27
+ ActionDispatch::Callbacks
28
+ end
13
29
  end
14
30
 
15
31
  def self.replace_proc?(last)
@@ -45,8 +61,20 @@ module ActiveReload
45
61
  end
46
62
 
47
63
  def self.replace_proc(&new)
48
- replaced = ActionDispatch::Callbacks.instance_variable_get(:@_call_callbacks).pop
49
- ActionDispatch::Callbacks.before(&new)
64
+ @replaced = proc_collection.pop
65
+ if rails31?
66
+ proc_source.to_prepare(&new)
67
+ else
68
+ proc_source.before(&new)
69
+ end
70
+ end
71
+
72
+ def self.rails3?
73
+ Rails::VERSION::MAJOR == 3
74
+ end
75
+
76
+ def self.rails31?
77
+ rails3? && Rails::VERSION::MINOR == 1
50
78
  end
51
79
 
52
80
 
@@ -1,3 +1,3 @@
1
1
  module ActiveReload
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,32 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '3.0.9'
4
+ gem 'active_reload', :path => '../../../active_reload'
5
+
6
+ # Bundle edge Rails instead:
7
+ # gem 'rails', :git => 'git://github.com/rails/rails.git'
8
+
9
+ gem 'sqlite3'
10
+
11
+ # Use unicorn as the web server
12
+ # gem 'unicorn'
13
+
14
+ # Deploy with Capistrano
15
+ # gem 'capistrano'
16
+
17
+ # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
18
+ # gem 'ruby-debug'
19
+ # gem 'ruby-debug19', :require => 'ruby-debug'
20
+
21
+ # Bundle the extra gems:
22
+ # gem 'bj'
23
+ # gem 'nokogiri'
24
+ # gem 'sqlite3-ruby', :require => 'sqlite3'
25
+ # gem 'aws-s3', :require => 'aws/s3'
26
+
27
+ # Bundle gems for the local environment. Make sure to
28
+ # put test-only gems in this group so their generators
29
+ # and rake tasks are available in development mode:
30
+ # group :development, :test do
31
+ # gem 'webrat'
32
+ # 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.