Changeset 4905
- Timestamp:
- 09/02/06 19:44:16 (2 years ago)
- Files:
-
- trunk/railties/README (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/railties/README
r4888 r4905 14 14 layer entitled Active Record. This layer allows you to present the data from 15 15 database rows as objects and embellish these data objects with business logic 16 methods. You can read more about Active Record in 16 methods. You can read more about Active Record in 17 17 link:files/vendor/rails/activerecord/README.html. 18 18 … … 22 22 unlike the relationship between the Active Record and Action Pack that is much 23 23 more separate. Each of these packages can be used independently outside of 24 Rails. You can read more about Action Pack in 24 Rails. You can read more about Action Pack in 25 25 link:files/vendor/rails/actionpack/README.html. 26 26 … … 28 28 == Getting started 29 29 30 1. Start the web server: <tt>ruby script/server</tt> (run with --help for options) 31 2. Go to http://localhost:3000/ and get "Welcome aboard: Youâre riding the Rails!" 32 3. Follow the guidelines to start developing your application 30 1. At the command prompt, start a new rails application using the rails command 31 and your application name. Ex: rails myapp 32 (If you've downloaded rails in a complete tgz or zip, this step is already done) 33 2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options) 34 3. Go to http://localhost:3000/ and get "Welcome aboard: Youâre riding the Rails!" 35 4. Follow the guidelines to start developing your application 33 36 34 37 35 == Web servers38 == Web Servers 36 39 37 Rails uses the built-in web server in Ruby called WEBrick by default, so you don't 38 have to install or configure anything to play around. 40 By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise 41 Rails will use the WEBrick, the webserver that ships with Ruby. When you run script/server, 42 Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures 43 that you can always get up and running quickly. 39 44 40 If you have lighttpd installed, though, it'll be used instead when running script/server. 41 It's considerably faster than WEBrick and suited for production use, but requires additional 45 Mongrel is a Ruby-based webserver with a C-component (which requires compilation) that is 46 suitable for development and deployment of Rails applications. If you have Ruby Gems installed, 47 getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>. 48 More info at: http://mongrel.rubyforge.org 49 50 If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than 51 Mongrel and WEBrick and also suited for production use, but requires additional 42 52 installation and currently only works well on OS X/Unix (Windows users are encouraged 43 to start with WEBrick). We recommend version 1.4.11 and higher. You can download it from53 to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from 44 54 http://www.lighttpd.net. 45 55 46 If you want something that's halfway between WEBrick and lighttpd, we heartily recommend 47 Mongrel. It's a Ruby-based web server with a C-component (so it requires compilation) that48 also works very well with Windows. See more at http://mongrel.rubyforge.org/.56 And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby 57 web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not 58 for production. 49 59 50 But of course its also possible to run Rails with the premiere open source web server Apache. 51 To get decent performance, though, you'll need to install FastCGI. For Apache 1.3, you want 52 to use mod_fastcgi. For Apache 2.0+, you want to use mod_fcgid. 53 54 See http://wiki.rubyonrails.com/rails/pages/FastCGI for more information on FastCGI. 55 56 == Example for Apache conf 57 58 <VirtualHost *:80> 59 ServerName rails 60 DocumentRoot /path/application/public/ 61 ErrorLog /path/application/log/server.log 62 63 <Directory /path/application/public/> 64 Options ExecCGI FollowSymLinks 65 AllowOverride all 66 Allow from all 67 Order allow,deny 68 </Directory> 69 </VirtualHost> 70 71 NOTE: Be sure that CGIs can be executed in that directory as well. So ExecCGI 72 should be on and ".cgi" should respond. All requests from 127.0.0.1 go 73 through CGI, so no Apache restart is necessary for changes. All other requests 74 go through FCGI (or mod_ruby), which requires a restart to show changes. 60 But of course its also possible to run Rails on any platform that supports FCGI. 61 Apache, LiteSpeed, IIS are just a few. For more information on FCGI, 62 please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI 75 63 76 64 77 65 == Debugging Rails 78 66 79 Have "tail -f" commands running on both the server.log, production.log, and 80 test.log files. Rails will automatically display debugging and runtime 81 information to these files. Debugging info will also be shown in the browser 82 on requests from 127.0.0.1. 67 Have "tail -f" commands running on the server.log and development.log. Rails will 68 automatically display debugging and runtime information to these files. Debugging 69 info will also be shown in the browser on requests from 127.0.0.1. 83 70 84 71 … … 95 82 end 96 83 end 97 84 98 85 So the controller will accept the action, run the first line, then present you 99 86 with a IRB prompt in the breakpointer window. Here you can do things like: … … 102 89 103 90 >> @posts.inspect 104 => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>, 91 => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>, 105 92 #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]" 106 93 >> @posts.first.title = "hello from a breakpoint" … … 109 96 ...and even better is that you can examine how your runtime objects actually work: 110 97 111 >> f = @posts.first 98 >> f = @posts.first 112 99 => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}> 113 100 >> f. … … 119 106 == Console 120 107 121 You can interact with the domain model by starting the console through script/console.108 You can interact with the domain model by starting the console through <tt>script/console</tt>. 122 109 Here you'll have all parts of the application configured, just like it is when the 123 110 application is running. You can inspect domain models, change values, and save to the … … 128 115 129 116 130 131 117 == Description of contents 132 118 … … 135 121 136 122 app/controllers 137 Holds controllers that should be named like weblog _controller.rb for138 automated URL mapping. All controllers should descend from 139 ActionController::Base.123 Holds controllers that should be named like weblogs_controller.rb for 124 automated URL mapping. All controllers should descend from ApplicationController 125 which itself descends from ActionController::Base. 140 126 141 127 app/models 142 128 Holds models that should be named like post.rb. 143 129 Most models will descend from ActiveRecord::Base. 144 130 145 131 app/views 146 132 Holds the template files for the view that should be named like 147 weblog/index.rhtml for the WeblogController#index action. All views use eRuby 148 syntax. This directory can also be used to keep stylesheets, images, and so on 149 that can be symlinked to public. 150 133 weblogs/index.rhtml for the WeblogsController#index action. All views use eRuby 134 syntax. 135 136 app/views/layouts 137 Holds the template files for layouts to be used with views. This models the common 138 header/footer method of wrapping views. In your views, define a layout using the 139 <tt>layout :default</tt> and create a file named default.rhtml. Inside default.rhtml, 140 call <% yield %> to render the view using this layout. 141 151 142 app/helpers 152 Holds view helpers that should be named like weblog_helper.rb. 153 154 app/apis 155 Holds API classes for web services. 143 Holds view helpers that should be named like weblogs_helper.rb. These are generated 144 for you automatically when using script/generate for controllers. Helpers can be used to 145 wrap functionality for your views into methods. 156 146 157 147 config … … 165 155 the sequence of Migrations for your schema. 166 156 157 doc 158 This directory is where your application documentation will be stored when generated 159 using <tt>rake doc:app</tt> 160 167 161 lib 168 162 Application specific libraries. Basically, any kind of custom code that doesn't 169 163 belong under controllers, models, or helpers. This directory is in the load path. 170 164 171 165 public 172 166 The directory available for the web server. Contains subdirectories for images, stylesheets, 173 and javascripts. Also contains the dispatchers and the default HTML files. 167 and javascripts. Also contains the dispatchers and the default HTML files. This should be 168 set as the DOCUMENT_ROOT of your web server. 174 169 175 170 script … … 177 172 178 173 test 179 Unit and functional tests along with fixtures. 174 Unit and functional tests along with fixtures. When using the script/generate scripts, template 175 test files will be generated for you and placed in this directory. 180 176 181 177 vendor