secure_headers 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of secure_headers might be problematic. Click here for more details.

Files changed (104) hide show
  1. data/.gitignore +9 -0
  2. data/.travis.yml +3 -2
  3. data/Gemfile +4 -0
  4. data/Guardfile +1 -1
  5. data/HISTORY.md +14 -0
  6. data/README.md +2 -2
  7. data/Rakefile +41 -1
  8. data/app/controllers/content_security_policy_controller.rb +19 -10
  9. data/fixtures/rails_3_2_12/.rspec +1 -0
  10. data/fixtures/rails_3_2_12/Gemfile +14 -0
  11. data/fixtures/rails_3_2_12/Guardfile +14 -0
  12. data/fixtures/rails_3_2_12/README.rdoc +261 -0
  13. data/fixtures/rails_3_2_12/Rakefile +7 -0
  14. data/fixtures/rails_3_2_12/app/controllers/application_controller.rb +4 -0
  15. data/fixtures/rails_3_2_12/app/controllers/other_things_controller.rb +5 -0
  16. data/fixtures/rails_3_2_12/app/controllers/things_controller.rb +6 -0
  17. data/fixtures/rails_3_2_12/app/models/.gitkeep +0 -0
  18. data/fixtures/rails_3_2_12/app/models/thing.rb +3 -0
  19. data/fixtures/rails_3_2_12/app/views/layouts/application.html.erb +14 -0
  20. data/fixtures/rails_3_2_12/app/views/other_things/index.html.erb +1 -0
  21. data/fixtures/rails_3_2_12/app/views/things/index.html.erb +21 -0
  22. data/fixtures/rails_3_2_12/config.ru +4 -0
  23. data/fixtures/rails_3_2_12/config/application.rb +68 -0
  24. data/fixtures/rails_3_2_12/config/boot.rb +6 -0
  25. data/fixtures/rails_3_2_12/config/database.yml +25 -0
  26. data/fixtures/rails_3_2_12/config/environment.rb +5 -0
  27. data/fixtures/rails_3_2_12/config/environments/development.rb +37 -0
  28. data/fixtures/rails_3_2_12/config/environments/production.rb +67 -0
  29. data/fixtures/rails_3_2_12/config/environments/test.rb +37 -0
  30. data/fixtures/rails_3_2_12/config/initializers/backtrace_silencers.rb +7 -0
  31. data/fixtures/rails_3_2_12/config/initializers/inflections.rb +15 -0
  32. data/fixtures/rails_3_2_12/config/initializers/mime_types.rb +5 -0
  33. data/fixtures/rails_3_2_12/config/initializers/secret_token.rb +7 -0
  34. data/fixtures/rails_3_2_12/config/initializers/secure_headers.rb +15 -0
  35. data/fixtures/rails_3_2_12/config/initializers/session_store.rb +8 -0
  36. data/fixtures/rails_3_2_12/config/initializers/wrap_parameters.rb +14 -0
  37. data/fixtures/rails_3_2_12/config/locales/en.yml +5 -0
  38. data/fixtures/rails_3_2_12/config/routes.rb +61 -0
  39. data/fixtures/rails_3_2_12/db/schema.rb +16 -0
  40. data/fixtures/rails_3_2_12/db/seeds.rb +7 -0
  41. data/fixtures/rails_3_2_12/lib/assets/.gitkeep +0 -0
  42. data/fixtures/rails_3_2_12/lib/tasks/.gitkeep +0 -0
  43. data/fixtures/rails_3_2_12/log/.gitkeep +0 -0
  44. data/fixtures/rails_3_2_12/spec/controllers/other_things_controller_spec.rb +40 -0
  45. data/fixtures/rails_3_2_12/spec/controllers/things_controller_spec.rb +47 -0
  46. data/fixtures/rails_3_2_12/spec/spec_helper.rb +19 -0
  47. data/fixtures/rails_3_2_12/vendor/assets/javascripts/.gitkeep +0 -0
  48. data/fixtures/rails_3_2_12/vendor/assets/stylesheets/.gitkeep +0 -0
  49. data/fixtures/rails_3_2_12/vendor/plugins/.gitkeep +0 -0
  50. data/fixtures/rails_3_2_12_no_init/.rspec +1 -0
  51. data/fixtures/rails_3_2_12_no_init/Gemfile +14 -0
  52. data/fixtures/rails_3_2_12_no_init/Guardfile +14 -0
  53. data/fixtures/rails_3_2_12_no_init/README.rdoc +261 -0
  54. data/fixtures/rails_3_2_12_no_init/Rakefile +7 -0
  55. data/fixtures/rails_3_2_12_no_init/app/controllers/application_controller.rb +4 -0
  56. data/fixtures/rails_3_2_12_no_init/app/controllers/other_things_controller.rb +7 -0
  57. data/fixtures/rails_3_2_12_no_init/app/controllers/things_controller.rb +5 -0
  58. data/fixtures/rails_3_2_12_no_init/app/models/.gitkeep +0 -0
  59. data/fixtures/rails_3_2_12_no_init/app/models/thing.rb +3 -0
  60. data/fixtures/rails_3_2_12_no_init/app/views/layouts/application.html.erb +14 -0
  61. data/fixtures/rails_3_2_12_no_init/app/views/other_things/index.html.erb +1 -0
  62. data/fixtures/rails_3_2_12_no_init/app/views/things/_form.html.erb +17 -0
  63. data/fixtures/rails_3_2_12_no_init/app/views/things/edit.html.erb +6 -0
  64. data/fixtures/rails_3_2_12_no_init/app/views/things/index.html.erb +21 -0
  65. data/fixtures/rails_3_2_12_no_init/app/views/things/new.html.erb +5 -0
  66. data/fixtures/rails_3_2_12_no_init/app/views/things/show.html.erb +5 -0
  67. data/fixtures/rails_3_2_12_no_init/config.ru +4 -0
  68. data/fixtures/rails_3_2_12_no_init/config/application.rb +68 -0
  69. data/fixtures/rails_3_2_12_no_init/config/boot.rb +6 -0
  70. data/fixtures/rails_3_2_12_no_init/config/database.yml +25 -0
  71. data/fixtures/rails_3_2_12_no_init/config/environment.rb +5 -0
  72. data/fixtures/rails_3_2_12_no_init/config/environments/development.rb +37 -0
  73. data/fixtures/rails_3_2_12_no_init/config/environments/production.rb +67 -0
  74. data/fixtures/rails_3_2_12_no_init/config/environments/test.rb +37 -0
  75. data/fixtures/rails_3_2_12_no_init/config/initializers/backtrace_silencers.rb +7 -0
  76. data/fixtures/rails_3_2_12_no_init/config/initializers/inflections.rb +15 -0
  77. data/fixtures/rails_3_2_12_no_init/config/initializers/mime_types.rb +5 -0
  78. data/fixtures/rails_3_2_12_no_init/config/initializers/secret_token.rb +7 -0
  79. data/fixtures/rails_3_2_12_no_init/config/initializers/session_store.rb +8 -0
  80. data/fixtures/rails_3_2_12_no_init/config/initializers/wrap_parameters.rb +14 -0
  81. data/fixtures/rails_3_2_12_no_init/config/locales/en.yml +5 -0
  82. data/fixtures/rails_3_2_12_no_init/config/routes.rb +61 -0
  83. data/fixtures/rails_3_2_12_no_init/db/schema.rb +16 -0
  84. data/fixtures/rails_3_2_12_no_init/db/seeds.rb +7 -0
  85. data/fixtures/rails_3_2_12_no_init/lib/assets/.gitkeep +0 -0
  86. data/fixtures/rails_3_2_12_no_init/lib/tasks/.gitkeep +0 -0
  87. data/fixtures/rails_3_2_12_no_init/log/.gitkeep +0 -0
  88. data/fixtures/rails_3_2_12_no_init/spec/controllers/other_things_controller_spec.rb +40 -0
  89. data/fixtures/rails_3_2_12_no_init/spec/controllers/things_controller_spec.rb +44 -0
  90. data/fixtures/rails_3_2_12_no_init/spec/spec_helper.rb +20 -0
  91. data/fixtures/rails_3_2_12_no_init/vendor/assets/javascripts/.gitkeep +0 -0
  92. data/fixtures/rails_3_2_12_no_init/vendor/assets/stylesheets/.gitkeep +0 -0
  93. data/fixtures/rails_3_2_12_no_init/vendor/plugins/.gitkeep +0 -0
  94. data/lib/secure_headers.rb +19 -15
  95. data/lib/secure_headers/headers/content_security_policy.rb +54 -113
  96. data/lib/secure_headers/headers/content_security_policy/browser_strategy.rb +70 -0
  97. data/lib/secure_headers/headers/content_security_policy/firefox_browser_strategy.rb +72 -0
  98. data/lib/secure_headers/headers/content_security_policy/ie_browser_strategy.rb +6 -0
  99. data/lib/secure_headers/headers/content_security_policy/webkit_browser_strategy.rb +9 -0
  100. data/lib/secure_headers/version.rb +1 -1
  101. data/{secure-headers.gemspec → secure_headers.gemspec} +0 -0
  102. data/spec/lib/secure_headers/headers/content_security_policy_spec.rb +72 -84
  103. data/travis.sh +10 -0
  104. metadata +93 -3
@@ -0,0 +1,16 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 0) do
15
+
16
+ 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
+ # Mayor.create(name: 'Emanuel', city: cities.first)
File without changes
File without changes
File without changes
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe OtherThingsController do
4
+ describe "headers" do
5
+ before(:each) do
6
+ # Chrome
7
+ request.env['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5'
8
+ end
9
+
10
+ it "sets the X-XSS-PROTECTION header" do
11
+ get :index
12
+ response.headers['X-XSS-Protection'].should == '1; mode=BLOCK'
13
+ end
14
+
15
+ it "sets the X-FRAME-OPTIONS header" do
16
+ get :index
17
+ response.headers['X-FRAME-OPTIONS'].should == 'SAMEORIGIN'
18
+ end
19
+
20
+ it "sets the X-WebKit-CSP header" do
21
+ get :index
22
+ response.headers['X-WebKit-CSP-Report-Only'].should == "default-src 'self'; img-src data:; report-uri somewhere;"
23
+ end
24
+
25
+ #mock ssl
26
+ it "sets the STRICT-TRANSPORT-SECURITY header" do
27
+ request.env['HTTPS'] = 'on'
28
+ get :index
29
+ response.headers['Strict-Transport-Security'].should == "max-age=315576000"
30
+ end
31
+
32
+ context "using IE" do
33
+ it "sets the X-CONTENT-TYPE-OPTIONS header" do
34
+ request.env['HTTP_USER_AGENT'] = "Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0"
35
+ get :index
36
+ response.headers['X-Content-Type-Options'].should == "nosniff"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ # This controller is meant to be something that inherits config from application controller
4
+ # all values are defaulted because no initializer is configured, and the values in app controller
5
+ # only provide csp => false
6
+
7
+ describe ThingsController do
8
+ describe "headers" do
9
+ before(:each) do
10
+ # Chrome
11
+ request.env['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5'
12
+ end
13
+
14
+ it "sets the X-XSS-PROTECTION header" do
15
+ get :index
16
+ response.headers['X-XSS-Protection'].should == '1; mode=BLOCK'
17
+ end
18
+
19
+ it "sets the X-FRAME-OPTIONS header" do
20
+ get :index
21
+ response.headers['X-FRAME-OPTIONS'].should == 'SAMEORIGIN'
22
+ end
23
+
24
+ it "sets the X-WebKit-CSP header" do
25
+ get :index
26
+ response.headers['X-WebKit-CSP-Report-Only'].should == nil
27
+ end
28
+
29
+ #mock ssl
30
+ it "sets the STRICT-TRANSPORT-SECURITY header" do
31
+ request.env['HTTPS'] = 'on'
32
+ get :index
33
+ response.headers['Strict-Transport-Security'].should == "max-age=315576000"
34
+ end
35
+
36
+ context "using IE" do
37
+ it "sets the X-CONTENT-TYPE-OPTIONS header" do
38
+ request.env['HTTP_USER_AGENT'] = "Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0"
39
+ get :index
40
+ response.headers['X-Content-Type-Options'].should == "nosniff"
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+
47
+ # response.headers['X-WebKit-CSP-Report-Only'].should == "default-src 'self'; report-uri somewhere"
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'spork'
3
+ #uncomment the following line to use spork with the debugger
4
+ #require 'spork/ext/ruby-debug'
5
+
6
+ # Spork.prefork do
7
+ # Loading more in this block will cause your tests to run faster. However,
8
+ # if you change any configuration or code from libraries loaded here, you'll
9
+ # need to restart spork for it take effect.
10
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
11
+ ENV["RAILS_ENV"] ||= 'test'
12
+ require File.expand_path("../../config/environment", __FILE__)
13
+ require 'rspec/rails'
14
+ require 'rspec/autorun'
15
+ # end
16
+
17
+ Spork.each_run do
18
+
19
+ end
File without changes
@@ -0,0 +1 @@
1
+ --color --format progress
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '3.2.12'
4
+ gem 'sqlite3'
5
+ gem 'rspec-rails', '>= 2.0.0'
6
+ gem 'secure_headers', :path => '../..'
7
+ gem 'spork'
8
+ gem 'debugger', :platform => :ruby_19
9
+ gem 'ruby-debug', :platform => :ruby_18
10
+ gem 'guard-rspec'
11
+ gem 'guard-spork'
12
+ gem 'rb-fsevent'
13
+ gem 'growl'
14
+
@@ -0,0 +1,14 @@
1
+ guard 'spork', :rspec_port => 1235, :aggressive_kill => false do
2
+ watch('spec/spec_helper.rb') { :rspec }
3
+ end
4
+
5
+ guard 'rspec', :cli => "--color --drb --drb-port 1235", :keep_failed => true, :all_after_pass => true, :focus_on_failed => true do
6
+ watch(%r{^spec/.+_spec\.rb$})
7
+ watch('../../../lib')
8
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
9
+ watch('spec/spec_helper.rb') { "spec" }
10
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
11
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
12
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
13
+ end
14
+
@@ -0,0 +1,261 @@
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.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.org/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
+ | |-- assets
160
+ | |-- images
161
+ | |-- javascripts
162
+ | `-- stylesheets
163
+ | |-- controllers
164
+ | |-- helpers
165
+ | |-- mailers
166
+ | |-- models
167
+ | `-- views
168
+ | `-- layouts
169
+ |-- config
170
+ | |-- environments
171
+ | |-- initializers
172
+ | `-- locales
173
+ |-- db
174
+ |-- doc
175
+ |-- lib
176
+ | `-- tasks
177
+ |-- log
178
+ |-- public
179
+ |-- script
180
+ |-- test
181
+ | |-- fixtures
182
+ | |-- functional
183
+ | |-- integration
184
+ | |-- performance
185
+ | `-- unit
186
+ |-- tmp
187
+ | |-- cache
188
+ | |-- pids
189
+ | |-- sessions
190
+ | `-- sockets
191
+ `-- vendor
192
+ |-- assets
193
+ `-- stylesheets
194
+ `-- plugins
195
+
196
+ app
197
+ Holds all the code that's specific to this particular application.
198
+
199
+ app/assets
200
+ Contains subdirectories for images, stylesheets, and JavaScript files.
201
+
202
+ app/controllers
203
+ Holds controllers that should be named like weblogs_controller.rb for
204
+ automated URL mapping. All controllers should descend from
205
+ ApplicationController which itself descends from ActionController::Base.
206
+
207
+ app/models
208
+ Holds models that should be named like post.rb. Models descend from
209
+ ActiveRecord::Base by default.
210
+
211
+ app/views
212
+ Holds the template files for the view that should be named like
213
+ weblogs/index.html.erb for the WeblogsController#index action. All views use
214
+ eRuby syntax by default.
215
+
216
+ app/views/layouts
217
+ Holds the template files for layouts to be used with views. This models the
218
+ common header/footer method of wrapping views. In your views, define a layout
219
+ using the <tt>layout :default</tt> and create a file named default.html.erb.
220
+ Inside default.html.erb, call <% yield %> to render the view using this
221
+ layout.
222
+
223
+ app/helpers
224
+ Holds view helpers that should be named like weblogs_helper.rb. These are
225
+ generated for you automatically when using generators for controllers.
226
+ Helpers can be used to wrap functionality for your views into methods.
227
+
228
+ config
229
+ Configuration files for the Rails environment, the routing map, the database,
230
+ and other dependencies.
231
+
232
+ db
233
+ Contains the database schema in schema.rb. db/migrate contains all the
234
+ sequence of Migrations for your schema.
235
+
236
+ doc
237
+ This directory is where your application documentation will be stored when
238
+ generated using <tt>rake doc:app</tt>
239
+
240
+ lib
241
+ Application specific libraries. Basically, any kind of custom code that
242
+ doesn't belong under controllers, models, or helpers. This directory is in
243
+ the load path.
244
+
245
+ public
246
+ The directory available for the web server. Also contains the dispatchers and the
247
+ default HTML files. This should be set as the DOCUMENT_ROOT of your web
248
+ server.
249
+
250
+ script
251
+ Helper scripts for automation and generation.
252
+
253
+ test
254
+ Unit and functional tests along with fixtures. When using the rails generate
255
+ command, template test files will be generated for you and placed in this
256
+ directory.
257
+
258
+ vendor
259
+ External libraries that the application depends on. Also includes the plugins
260
+ subdirectory. If the app has frozen rails, those gems also go here, under
261
+ vendor/rails/. This directory is in the load path.