clearance 0.10.0 → 0.10.1

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

Potentially problematic release.


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

Files changed (133) hide show
  1. data/CHANGELOG.md +6 -0
  2. data/README.md +15 -4
  3. data/VERSION +1 -1
  4. data/app/controllers/clearance/passwords_controller.rb +14 -6
  5. data/lib/clearance.rb +0 -3
  6. data/lib/clearance/shoulda_macros.rb +1 -176
  7. data/lib/rails/generators/clearance_features_templates/features/password_reset.feature +4 -3
  8. data/lib/rails/generators/clearance_features_templates/features/sign_in.feature +3 -2
  9. data/lib/rails/generators/clearance_features_templates/features/sign_out.feature +4 -3
  10. data/lib/rails/generators/clearance_features_templates/features/sign_up.feature +3 -2
  11. data/lib/rails/generators/clearance_features_templates/features/step_definitions/clearance_steps.rb +2 -10
  12. data/spec/rails_root/Gemfile.lock +143 -0
  13. data/spec/rails_root/app/views/passwords/edit.html.erb +21 -0
  14. data/spec/rails_root/app/views/passwords/new.html.erb +15 -0
  15. data/spec/rails_root/app/views/sessions/new.html.erb +21 -0
  16. data/spec/rails_root/app/views/users/_inputs.html.erb +6 -0
  17. data/spec/rails_root/app/views/users/new.html.erb +10 -0
  18. data/spec/rails_root/db/development.sqlite3 +0 -0
  19. data/spec/rails_root/db/migrate/20110209234521_clearance_create_users.rb +19 -0
  20. data/spec/rails_root/db/schema.rb +28 -0
  21. data/spec/rails_root/db/test.sqlite3 +0 -0
  22. data/spec/rails_root/features/password_reset.feature +40 -0
  23. data/spec/rails_root/features/sign_in.feature +28 -0
  24. data/spec/rails_root/features/sign_out.feature +16 -0
  25. data/spec/rails_root/features/sign_up.feature +21 -0
  26. data/spec/rails_root/features/step_definitions/clearance_steps.rb +109 -0
  27. data/spec/rails_root/log/development.log +536 -0
  28. data/spec/rails_root/log/test.log +7600 -0
  29. data/spec/rails_root/test/factories/clearance.rb +13 -0
  30. data/spec/rails_root/test/functional/accounts_controller_test.rb +22 -0
  31. data/spec/rails_root/test/performance/browsing_test.rb +9 -0
  32. data/spec/rails_root/test/test_helper.rb +13 -0
  33. data/spec/rails_root/vendor/Gemfile +17 -0
  34. data/spec/rails_root/vendor/Gemfile.lock +143 -0
  35. data/spec/rails_root/vendor/README +244 -0
  36. data/spec/rails_root/vendor/Rakefile +10 -0
  37. data/spec/rails_root/vendor/app/controllers/accounts_controller.rb +10 -0
  38. data/spec/rails_root/vendor/app/controllers/application_controller.rb +6 -0
  39. data/spec/rails_root/vendor/app/helpers/application_helper.rb +2 -0
  40. data/spec/rails_root/vendor/app/models/user.rb +3 -0
  41. data/spec/rails_root/vendor/app/views/accounts/edit.html.erb +0 -0
  42. data/spec/rails_root/vendor/app/views/layouts/application.html.erb +24 -0
  43. data/spec/rails_root/vendor/app/views/passwords/edit.html.erb +21 -0
  44. data/spec/rails_root/vendor/app/views/passwords/new.html.erb +15 -0
  45. data/spec/rails_root/vendor/app/views/sessions/new.html.erb +21 -0
  46. data/spec/rails_root/vendor/app/views/users/_inputs.html.erb +6 -0
  47. data/spec/rails_root/vendor/app/views/users/new.html.erb +10 -0
  48. data/spec/rails_root/vendor/config.ru +4 -0
  49. data/spec/rails_root/vendor/config/application.rb +46 -0
  50. data/spec/rails_root/vendor/config/boot.rb +6 -0
  51. data/spec/rails_root/vendor/config/cucumber.yml +8 -0
  52. data/spec/rails_root/vendor/config/database.yml +25 -0
  53. data/spec/rails_root/vendor/config/environment.rb +7 -0
  54. data/spec/rails_root/vendor/config/environments/development.rb +21 -0
  55. data/spec/rails_root/vendor/config/environments/production.rb +42 -0
  56. data/spec/rails_root/vendor/config/environments/test.rb +34 -0
  57. data/spec/rails_root/vendor/config/initializers/backtrace_silencers.rb +7 -0
  58. data/spec/rails_root/vendor/config/initializers/clearance.rb +3 -0
  59. data/spec/rails_root/vendor/config/initializers/inflections.rb +10 -0
  60. data/spec/rails_root/vendor/config/initializers/mime_types.rb +5 -0
  61. data/spec/rails_root/vendor/config/initializers/secret_token.rb +7 -0
  62. data/spec/rails_root/vendor/config/initializers/session_store.rb +8 -0
  63. data/spec/rails_root/vendor/config/locales/en.yml +5 -0
  64. data/spec/rails_root/vendor/config/routes.rb +61 -0
  65. data/spec/rails_root/vendor/db/development.sqlite3 +0 -0
  66. data/spec/rails_root/vendor/db/migrate/20101220184900_clearance_create_users.rb +20 -0
  67. data/spec/rails_root/vendor/db/schema.rb +29 -0
  68. data/spec/rails_root/vendor/db/test.sqlite3 +0 -0
  69. data/spec/rails_root/vendor/doc/README_FOR_APP +2 -0
  70. data/spec/rails_root/vendor/features/password_reset.feature +33 -0
  71. data/spec/rails_root/vendor/features/sign_in.feature +35 -0
  72. data/spec/rails_root/vendor/features/sign_out.feature +15 -0
  73. data/spec/rails_root/vendor/features/sign_up.feature +45 -0
  74. data/spec/rails_root/vendor/features/step_definitions/clearance_steps.rb +138 -0
  75. data/spec/rails_root/vendor/features/step_definitions/web_steps.rb +219 -0
  76. data/spec/rails_root/vendor/features/support/env.rb +57 -0
  77. data/spec/rails_root/vendor/features/support/paths.rb +45 -0
  78. data/spec/rails_root/vendor/lib/tasks/cucumber.rake +53 -0
  79. data/spec/rails_root/vendor/log/development.log +663 -0
  80. data/spec/rails_root/vendor/log/test.log +22745 -0
  81. data/spec/rails_root/vendor/public/404.html +26 -0
  82. data/spec/rails_root/vendor/public/422.html +26 -0
  83. data/spec/rails_root/vendor/public/500.html +26 -0
  84. data/spec/rails_root/vendor/public/favicon.ico +0 -0
  85. data/spec/rails_root/vendor/public/images/rails.png +0 -0
  86. data/spec/rails_root/vendor/public/javascripts/application.js +2 -0
  87. data/spec/rails_root/vendor/public/javascripts/controls.js +965 -0
  88. data/spec/rails_root/vendor/public/javascripts/dragdrop.js +974 -0
  89. data/spec/rails_root/vendor/public/javascripts/effects.js +1123 -0
  90. data/spec/rails_root/vendor/public/javascripts/prototype.js +4874 -0
  91. data/spec/rails_root/vendor/public/javascripts/rails.js +118 -0
  92. data/spec/rails_root/vendor/public/robots.txt +5 -0
  93. data/spec/rails_root/vendor/script/cucumber +10 -0
  94. data/spec/rails_root/vendor/script/rails +9 -0
  95. data/spec/rails_root/vendor/test/factories/clearance.rb +13 -0
  96. data/spec/rails_root/vendor/test/functional/accounts_controller_test.rb +22 -0
  97. data/spec/rails_root/vendor/test/performance/browsing_test.rb +9 -0
  98. data/spec/rails_root/vendor/test/test_helper.rb +13 -0
  99. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/MIT-LICENSE +20 -0
  100. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/README +13 -0
  101. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/Rakefile +10 -0
  102. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/init.rb +5 -0
  103. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/lib/action_view/helpers/dynamic_form.rb +300 -0
  104. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/lib/action_view/locale/en.yml +8 -0
  105. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/test/dynamic_form_i18n_test.rb +42 -0
  106. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/test/dynamic_form_test.rb +370 -0
  107. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/test/test_helper.rb +9 -0
  108. data/test/controllers/passwords_controller_test.rb +19 -0
  109. data/test/models/clearance_mailer_test.rb +1 -1
  110. data/test/rails_root/Gemfile.lock +145 -0
  111. data/test/rails_root/app/views/passwords/edit.html.erb +21 -0
  112. data/test/rails_root/app/views/passwords/new.html.erb +15 -0
  113. data/test/rails_root/app/views/sessions/new.html.erb +21 -0
  114. data/test/rails_root/app/views/users/_inputs.html.erb +6 -0
  115. data/test/rails_root/app/views/users/new.html.erb +10 -0
  116. data/test/rails_root/db/development.sqlite3 +0 -0
  117. data/test/rails_root/db/migrate/20110209234101_clearance_create_users.rb +19 -0
  118. data/test/rails_root/db/schema.rb +28 -0
  119. data/test/rails_root/db/test.sqlite3 +0 -0
  120. data/test/rails_root/features/password_reset.feature +40 -0
  121. data/test/rails_root/features/sign_in.feature +28 -0
  122. data/test/rails_root/features/sign_out.feature +16 -0
  123. data/test/rails_root/features/sign_up.feature +21 -0
  124. data/test/rails_root/features/step_definitions/clearance_steps.rb +109 -0
  125. data/test/rails_root/log/development.log +938 -0
  126. data/test/rails_root/log/test.log +20303 -0
  127. data/test/test_helper.rb +1 -0
  128. metadata +263 -42
  129. data/clearance.gemspec +0 -198
  130. data/cucumber.yml +0 -4
  131. data/init.rb +0 -1
  132. data/lib/clearance/extensions/errors.rb +0 -6
  133. data/lib/clearance/extensions/rescue.rb +0 -5
@@ -0,0 +1,13 @@
1
+ Factory.sequence :email do |n|
2
+ "user#{n}@example.com"
3
+ end
4
+
5
+ Factory.define :user do |user|
6
+ user.email { Factory.next :email }
7
+ user.password { "password" }
8
+ user.password_confirmation { "password" }
9
+ end
10
+
11
+ Factory.define :email_confirmed_user, :parent => :user do |user|
12
+ user.after_build { warn "[DEPRECATION] The :email_confirmed_user factory is deprecated, please use the :user factory instead." }
13
+ end
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+
3
+ class AccountsControllerTest < ActionController::TestCase
4
+
5
+ context "when signed out" do
6
+ setup { sign_out }
7
+ should_deny_access_on :get, :edit
8
+ end
9
+
10
+ context "on POST to create" do
11
+ setup do
12
+ post :create
13
+ end
14
+
15
+ should_deny_access
16
+
17
+ should "not store location" do
18
+ assert session[:return_to].nil?
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+ require 'rails/performance_test_help'
3
+
4
+ # Profiling results for each test method are written to tmp/performance.
5
+ class BrowsingTest < ActionDispatch::PerformanceTest
6
+ def test_homepage
7
+ get '/'
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7
+ #
8
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
+ # -- they do not yet inherit this setting
10
+ fixtures :all
11
+
12
+ # Add more helper methods to be used by all tests here...
13
+ end
@@ -0,0 +1,17 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '3.0.0'
4
+
5
+ gem 'sqlite3-ruby', :require => 'sqlite3'
6
+
7
+ gem 'capybara', '0.4.0'
8
+ gem 'cucumber', '0.10.0'
9
+ gem 'cucumber-rails', '0.3.2'
10
+ gem 'factory_girl_rails', '1.0'
11
+ gem 'formtastic', '1.1.0.beta'
12
+ gem 'launchy', '0.3.7'
13
+ gem 'mocha', '0.9.8'
14
+ gem 'nokogiri', '1.4.1'
15
+ gem 'shoulda', '2.11.3'
16
+
17
+ gem 'clearance', :path => '../..'
@@ -0,0 +1,143 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ clearance (0.9.0.rc9)
5
+ rails (~> 3.0.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.0)
12
+ actionpack (= 3.0.0)
13
+ mail (~> 2.2.5)
14
+ actionpack (3.0.0)
15
+ activemodel (= 3.0.0)
16
+ activesupport (= 3.0.0)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.4.1)
20
+ rack (~> 1.2.1)
21
+ rack-mount (~> 0.6.12)
22
+ rack-test (~> 0.5.4)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.0)
25
+ activesupport (= 3.0.0)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.4.1)
28
+ activerecord (3.0.0)
29
+ activemodel (= 3.0.0)
30
+ activesupport (= 3.0.0)
31
+ arel (~> 1.0.0)
32
+ tzinfo (~> 0.3.23)
33
+ activeresource (3.0.0)
34
+ activemodel (= 3.0.0)
35
+ activesupport (= 3.0.0)
36
+ activesupport (3.0.0)
37
+ arel (1.0.1)
38
+ activesupport (~> 3.0.0)
39
+ builder (2.1.2)
40
+ capybara (0.4.0)
41
+ celerity (>= 0.7.9)
42
+ culerity (>= 0.2.4)
43
+ mime-types (>= 1.16)
44
+ nokogiri (>= 1.3.3)
45
+ rack (>= 1.0.0)
46
+ rack-test (>= 0.5.4)
47
+ selenium-webdriver (>= 0.0.27)
48
+ xpath (~> 0.1.2)
49
+ celerity (0.8.6)
50
+ childprocess (0.1.4)
51
+ ffi (~> 0.6.3)
52
+ configuration (1.1.0)
53
+ cucumber (0.10.0)
54
+ builder (>= 2.1.2)
55
+ diff-lcs (~> 1.1.2)
56
+ gherkin (~> 2.3.2)
57
+ json (~> 1.4.6)
58
+ term-ansicolor (~> 1.0.5)
59
+ cucumber-rails (0.3.2)
60
+ cucumber (>= 0.8.0)
61
+ culerity (0.2.13)
62
+ diff-lcs (1.1.2)
63
+ erubis (2.6.6)
64
+ abstract (>= 1.0.0)
65
+ factory_girl (1.3.2)
66
+ factory_girl_rails (1.0)
67
+ factory_girl (~> 1.3)
68
+ rails (>= 3.0.0.beta4)
69
+ ffi (0.6.3)
70
+ rake (>= 0.8.7)
71
+ formtastic (1.1.0.beta)
72
+ actionpack (>= 2.3.0)
73
+ activesupport (>= 2.3.0)
74
+ i18n (>= 0.4.0)
75
+ gherkin (2.3.2)
76
+ json (~> 1.4.6)
77
+ term-ansicolor (~> 1.0.5)
78
+ i18n (0.4.1)
79
+ json (1.4.6)
80
+ json_pure (1.4.6)
81
+ launchy (0.3.7)
82
+ configuration (>= 0.0.5)
83
+ rake (>= 0.8.1)
84
+ mail (2.2.5)
85
+ activesupport (>= 2.3.6)
86
+ mime-types
87
+ treetop (>= 1.4.5)
88
+ mime-types (1.16)
89
+ mocha (0.9.8)
90
+ rake
91
+ nokogiri (1.4.1)
92
+ polyglot (0.3.1)
93
+ rack (1.2.1)
94
+ rack-mount (0.6.13)
95
+ rack (>= 1.0.0)
96
+ rack-test (0.5.4)
97
+ rack (>= 1.0)
98
+ rails (3.0.0)
99
+ actionmailer (= 3.0.0)
100
+ actionpack (= 3.0.0)
101
+ activerecord (= 3.0.0)
102
+ activeresource (= 3.0.0)
103
+ activesupport (= 3.0.0)
104
+ bundler (~> 1.0.0)
105
+ railties (= 3.0.0)
106
+ railties (3.0.0)
107
+ actionpack (= 3.0.0)
108
+ activesupport (= 3.0.0)
109
+ rake (>= 0.8.4)
110
+ thor (~> 0.14.0)
111
+ rake (0.8.7)
112
+ rubyzip (0.9.4)
113
+ selenium-webdriver (0.1.1)
114
+ childprocess (= 0.1.4)
115
+ ffi (~> 0.6.3)
116
+ json_pure
117
+ rubyzip
118
+ shoulda (2.11.3)
119
+ sqlite3-ruby (1.3.1)
120
+ term-ansicolor (1.0.5)
121
+ thor (0.14.0)
122
+ treetop (1.4.8)
123
+ polyglot (>= 0.3.1)
124
+ tzinfo (0.3.23)
125
+ xpath (0.1.2)
126
+ nokogiri (~> 1.3)
127
+
128
+ PLATFORMS
129
+ ruby
130
+
131
+ DEPENDENCIES
132
+ capybara (= 0.4.0)
133
+ clearance!
134
+ cucumber (= 0.10.0)
135
+ cucumber-rails (= 0.3.2)
136
+ factory_girl_rails (= 1.0)
137
+ formtastic (= 1.1.0.beta)
138
+ launchy (= 0.3.7)
139
+ mocha (= 0.9.8)
140
+ nokogiri (= 1.4.1)
141
+ rails (= 3.0.0)
142
+ shoulda (= 2.11.3)
143
+ sqlite3-ruby
@@ -0,0 +1,244 @@
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" templates
7
+ that are primarily responsible for inserting pre-built data in between HTML tags.
8
+ The model contains the "smart" domain objects (such as Account, Product, Person,
9
+ Post) that holds all the business logic and knows how to persist themselves to
10
+ a database. The controller handles the incoming requests (such as Save New Account,
11
+ Update Product, Show Post) by manipulating the model and directing data to the view.
12
+
13
+ In Rails, the model is handled by what's called an object-relational mapping
14
+ layer entitled Active Record. This layer allows you to present the data from
15
+ database rows as objects and embellish these data objects with business logic
16
+ methods. You can read more about Active Record in
17
+ link:files/vendor/rails/activerecord/README.html.
18
+
19
+ The controller and view are handled by the Action Pack, which handles both
20
+ layers by its two parts: Action View and Action Controller. These two layers
21
+ are bundled in a single package due to their heavy interdependence. This is
22
+ unlike the relationship between the Active Record and Action Pack that is much
23
+ more separate. Each of these packages can be used independently outside of
24
+ Rails. You can read more about Action Pack in
25
+ link:files/vendor/rails/actionpack/README.html.
26
+
27
+
28
+ == Getting Started
29
+
30
+ 1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
31
+ and your application name. Ex: rails myapp
32
+ 2. Change directory into myapp and start the web server: <tt>rails server</tt> (run with --help for options)
33
+ 3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
34
+ 4. Follow the guidelines to start developing your application
35
+
36
+
37
+ == Web Servers
38
+
39
+ By default, Rails will try to use Mongrel if it's installed when started with <tt>rails server</tt>, otherwise
40
+ Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails
41
+ with a variety of other web servers.
42
+
43
+ Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
44
+ suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
45
+ getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
46
+ More info at: http://mongrel.rubyforge.org
47
+
48
+ Say other Ruby web servers like Thin and Ebb or regular web servers like Apache or LiteSpeed or
49
+ Lighttpd or IIS. The Ruby web servers are run through Rack and the latter can either be setup to use
50
+ FCGI or proxy to a pack of Mongrels/Thin/Ebb servers.
51
+
52
+ == Apache .htaccess example for FCGI/CGI
53
+
54
+ # General Apache options
55
+ AddHandler fastcgi-script .fcgi
56
+ AddHandler cgi-script .cgi
57
+ Options +FollowSymLinks +ExecCGI
58
+
59
+ # If you don't want Rails to look in certain directories,
60
+ # use the following rewrite rules so that Apache won't rewrite certain requests
61
+ #
62
+ # Example:
63
+ # RewriteCond %{REQUEST_URI} ^/notrails.*
64
+ # RewriteRule .* - [L]
65
+
66
+ # Redirect all requests not available on the filesystem to Rails
67
+ # By default the cgi dispatcher is used which is very slow
68
+ #
69
+ # For better performance replace the dispatcher with the fastcgi one
70
+ #
71
+ # Example:
72
+ # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
73
+ RewriteEngine On
74
+
75
+ # If your Rails application is accessed via an Alias directive,
76
+ # then you MUST also set the RewriteBase in this htaccess file.
77
+ #
78
+ # Example:
79
+ # Alias /myrailsapp /path/to/myrailsapp/public
80
+ # RewriteBase /myrailsapp
81
+
82
+ RewriteRule ^$ index.html [QSA]
83
+ RewriteRule ^([^.]+)$ $1.html [QSA]
84
+ RewriteCond %{REQUEST_FILENAME} !-f
85
+ RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
86
+
87
+ # In case Rails experiences terminal errors
88
+ # Instead of displaying this message you can supply a file here which will be rendered instead
89
+ #
90
+ # Example:
91
+ # ErrorDocument 500 /500.html
92
+
93
+ ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
94
+
95
+
96
+ == Debugging Rails
97
+
98
+ Sometimes your application goes wrong. Fortunately there are a lot of tools that
99
+ will help you debug it and get it back on the rails.
100
+
101
+ First area to check is the application log files. Have "tail -f" commands running
102
+ on the server.log and development.log. Rails will automatically display debugging
103
+ and runtime information to these files. Debugging info will also be shown in the
104
+ browser on requests from 127.0.0.1.
105
+
106
+ You can also log your own messages directly into the log file from your code using
107
+ the Ruby logger class from inside your controllers. Example:
108
+
109
+ class WeblogController < ActionController::Base
110
+ def destroy
111
+ @weblog = Weblog.find(params[:id])
112
+ @weblog.destroy
113
+ logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
114
+ end
115
+ end
116
+
117
+ The result will be a message in your log file along the lines of:
118
+
119
+ Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
120
+
121
+ More information on how to use the logger is at http://www.ruby-doc.org/core/
122
+
123
+ Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
124
+
125
+ * The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
126
+ * Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
127
+
128
+ These two online (and free) books will bring you up to speed on the Ruby language
129
+ and also on programming in general.
130
+
131
+
132
+ == Debugger
133
+
134
+ Debugger support is available through the debugger command when you start your Mongrel or
135
+ Webrick server with --debugger. This means that you can break out of execution at any point
136
+ in the code, investigate and change the model, AND then resume execution!
137
+ You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
138
+ Example:
139
+
140
+ class WeblogController < ActionController::Base
141
+ def index
142
+ @posts = Post.find(:all)
143
+ debugger
144
+ end
145
+ end
146
+
147
+ So the controller will accept the action, run the first line, then present you
148
+ with a IRB prompt in the server window. Here you can do things like:
149
+
150
+ >> @posts.inspect
151
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
152
+ #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
153
+ >> @posts.first.title = "hello from a debugger"
154
+ => "hello from a debugger"
155
+
156
+ ...and even better is that you can examine how your runtime objects actually work:
157
+
158
+ >> f = @posts.first
159
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
160
+ >> f.
161
+ Display all 152 possibilities? (y or n)
162
+
163
+ Finally, when you're ready to resume execution, you enter "cont"
164
+
165
+
166
+ == Console
167
+
168
+ You can interact with the domain model by starting the console through <tt>rails console</tt>.
169
+ Here you'll have all parts of the application configured, just like it is when the
170
+ application is running. You can inspect domain models, change values, and save to the
171
+ database. Starting the script without arguments will launch it in the development environment.
172
+ Passing an argument will specify a different environment, like <tt>rails console production</tt>.
173
+
174
+ To reload your controllers and models after launching the console run <tt>reload!</tt>
175
+
176
+ == dbconsole
177
+
178
+ You can go to the command line of your database directly through <tt>rails dbconsole</tt>.
179
+ You would be connected to the database with the credentials defined in database.yml.
180
+ Starting the script without arguments will connect you to the development database. Passing an
181
+ argument will connect you to a different database, like <tt>rails dbconsole production</tt>.
182
+ Currently works for mysql, postgresql and sqlite.
183
+
184
+ == Description of Contents
185
+
186
+ app
187
+ Holds all the code that's specific to this particular application.
188
+
189
+ app/controllers
190
+ Holds controllers that should be named like weblogs_controller.rb for
191
+ automated URL mapping. All controllers should descend from ApplicationController
192
+ which itself descends from ActionController::Base.
193
+
194
+ app/models
195
+ Holds models that should be named like post.rb.
196
+ Most models will descend from ActiveRecord::Base.
197
+
198
+ app/views
199
+ Holds the template files for the view that should be named like
200
+ weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
201
+ syntax.
202
+
203
+ app/views/layouts
204
+ Holds the template files for layouts to be used with views. This models the common
205
+ header/footer method of wrapping views. In your views, define a layout using the
206
+ <tt>layout :default</tt> and create a file named default.html.erb. Inside default.html.erb,
207
+ call <% yield %> to render the view using this layout.
208
+
209
+ app/helpers
210
+ Holds view helpers that should be named like weblogs_helper.rb. These are generated
211
+ for you automatically when using rails generate for controllers. Helpers can be used to
212
+ wrap functionality for your views into methods.
213
+
214
+ config
215
+ Configuration files for the Rails environment, the routing map, the database, and other dependencies.
216
+
217
+ db
218
+ Contains the database schema in schema.rb. db/migrate contains all
219
+ the sequence of Migrations for your schema.
220
+
221
+ doc
222
+ This directory is where your application documentation will be stored when generated
223
+ using <tt>rake doc:app</tt>
224
+
225
+ lib
226
+ Application specific libraries. Basically, any kind of custom code that doesn't
227
+ belong under controllers, models, or helpers. This directory is in the load path.
228
+
229
+ public
230
+ The directory available for the web server. Contains subdirectories for images, stylesheets,
231
+ and javascripts. Also contains the dispatchers and the default HTML files. This should be
232
+ set as the DOCUMENT_ROOT of your web server.
233
+
234
+ script
235
+ Helper scripts for automation and generation.
236
+
237
+ test
238
+ Unit and functional tests along with fixtures. When using the rails generate command, template
239
+ test files will be generated for you and placed in this directory.
240
+
241
+ vendor
242
+ External libraries that the application depends on. Also includes the plugins subdirectory.
243
+ If the app has frozen rails, those gems also go here, under vendor/rails/.
244
+ This directory is in the load path.