Made mwamko-stop perfect
[mwamko.git] / README
blobb14039b7916c7c16de220d77cea919d39faaa8f1
1 == Welcome to Mwamko
4 == Getting started with Rails
6 1. Start the web server: <tt>ruby script/server</tt> (run with --help for options)
7 2. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!"
8 3. Follow the guidelines to start developing your application
11 == Web servers
13 Rails uses the built-in web server in Ruby called WEBrick by default, so you don't
14 have to install or configure anything to play around. 
16 If you have lighttpd installed, though, it'll be used instead when running script/server.
17 It's considerably faster than WEBrick and suited for production use, but requires additional
18 installation and currently only works well on OS X/Unix (Windows users are encouraged
19 to start with WEBrick). We recommend version 1.4.11 and higher. You can download it from
20 http://www.lighttpd.net.
22 If you want something that's halfway between WEBrick and lighttpd, we heartily recommend
23 Mongrel. It's a Ruby-based web server with a C-component (so it requires compilation) that
24 also works very well with Windows. See more at http://mongrel.rubyforge.org/.
26 But of course its also possible to run Rails with the premiere open source web server Apache.
27 To get decent performance, though, you'll need to install FastCGI. For Apache 1.3, you want
28 to use mod_fastcgi. For Apache 2.0+, you want to use mod_fcgid.
30 See http://wiki.rubyonrails.com/rails/pages/FastCGI for more information on FastCGI.
32 == Example for Apache conf
34   <VirtualHost *:80>
35     ServerName rails
36     DocumentRoot /path/application/public/
37     ErrorLog /path/application/log/server.log
38   
39     <Directory /path/application/public/>
40       Options ExecCGI FollowSymLinks
41       AllowOverride all
42       Allow from all
43       Order allow,deny
44     </Directory>
45   </VirtualHost>
47 NOTE: Be sure that CGIs can be executed in that directory as well. So ExecCGI
48 should be on and ".cgi" should respond. All requests from 127.0.0.1 go
49 through CGI, so no Apache restart is necessary for changes. All other requests
50 go through FCGI (or mod_ruby), which requires a restart to show changes.
53 == Debugging Rails
55 Have "tail -f" commands running on both the server.log, production.log, and
56 test.log files. Rails will automatically display debugging and runtime
57 information to these files. Debugging info will also be shown in the browser
58 on requests from 127.0.0.1.
61 == Breakpoints
63 Breakpoint support is available through the script/breakpointer client. This
64 means that you can break out of execution at any point in the code, investigate
65 and change the model, AND then resume execution! Example:
67   class WeblogController < ActionController::Base
68     def index
69       @posts = Post.find_all
70       breakpoint "Breaking out from the list"
71     end
72   end
73   
74 So the controller will accept the action, run the first line, then present you
75 with a IRB prompt in the breakpointer window. Here you can do things like:
77 Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'
79   >> @posts.inspect
80   => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>, 
81        #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
82   >> @posts.first.title = "hello from a breakpoint"
83   => "hello from a breakpoint"
85 ...and even better is that you can examine how your runtime objects actually work:
87   >> f = @posts.first 
88   => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
89   >> f.
90   Display all 152 possibilities? (y or n)
92 Finally, when you're ready to resume execution, you press CTRL-D
95 == Console
97 You can interact with the domain model by starting the console through script/console. 
98 Here you'll have all parts of the application configured, just like it is when the
99 application is running. You can inspect domain models, change values, and save to the
100 database. Starting the script without arguments will launch it in the development environment.
101 Passing an argument will specify a different environment, like <tt>script/console production</tt>.
103 To reload your controllers and models after launching the console run <tt>reload!</tt>
107 == Description of contents
110   Holds all the code that's specific to this particular application.
112 app/controllers
113   Holds controllers that should be named like weblog_controller.rb for
114   automated URL mapping. All controllers should descend from
115   ActionController::Base.
117 app/models
118   Holds models that should be named like post.rb.
119   Most models will descend from ActiveRecord::Base.
120   
121 app/views
122   Holds the template files for the view that should be named like
123   weblog/index.rhtml for the WeblogController#index action. All views use eRuby
124   syntax. This directory can also be used to keep stylesheets, images, and so on
125   that can be symlinked to public.
126   
127 app/helpers
128   Holds view helpers that should be named like weblog_helper.rb.
130 app/apis
131   Holds API classes for web services.
133 config
134   Configuration files for the Rails environment, the routing map, the database, and other dependencies.
136 components
137   Self-contained mini-applications that can bundle together controllers, models, and views.
140   Contains the database schema in schema.rb.  db/migrate contains all
141   the sequence of Migrations for your schema.
144   Application specific libraries. Basically, any kind of custom code that doesn't
145   belong under controllers, models, or helpers. This directory is in the load path.
146     
147 public
148   The directory available for the web server. Contains subdirectories for images, stylesheets,
149   and javascripts. Also contains the dispatchers and the default HTML files.
151 script
152   Helper scripts for automation and generation.
154 test
155   Unit and functional tests along with fixtures.
157 vendor
158   External libraries that the application depends on. Also includes the plugins subdirectory.
159   This directory is in the load path.