提交 02b9c22d 编写于 作者: V Vijay Dev

Merge branch 'master' of github.com:lifo/docrails

Conflicts:
	guides/source/engines.textile
......@@ -74,7 +74,7 @@ def clear_respond_to
#
# respond_to do |format|
# format.html
# format.xml { render :xml => @people.to_xml }
# format.xml { render :xml => @people }
# end
# end
#
......@@ -389,7 +389,7 @@ def retrieve_collector_from_mimes(mimes=nil, &block) #:nodoc:
#
# respond_to do |format|
# format.html
# format.xml { render :xml => @people.to_xml }
# format.xml { render :xml => @people }
# end
#
# In this usage, the argument passed to the block (+format+ above) is an
......
......@@ -63,7 +63,7 @@ module ActionController #:nodoc:
#
# def create
# @project = Project.find(params[:project_id])
# @task = @project.comments.build(params[:task])
# @task = @project.tasks.build(params[:task])
# flash[:notice] = 'Task was successfully created.' if @task.save
# respond_with(@project, @task)
# end
......
......@@ -57,21 +57,21 @@ def exec_query(sql, name = 'SQL', binds = [])
end
# Executes insert +sql+ statement in the context of this connection using
# +binds+ as the bind substitutes. +name+ is the logged along with
# +binds+ as the bind substitutes. +name+ is logged along with
# the executed +sql+ statement.
def exec_insert(sql, name, binds)
exec_query(sql, name, binds)
end
# Executes delete +sql+ statement in the context of this connection using
# +binds+ as the bind substitutes. +name+ is the logged along with
# +binds+ as the bind substitutes. +name+ is logged along with
# the executed +sql+ statement.
def exec_delete(sql, name, binds)
exec_query(sql, name, binds)
end
# Executes update +sql+ statement in the context of this connection using
# +binds+ as the bind substitutes. +name+ is the logged along with
# +binds+ as the bind substitutes. +name+ is logged along with
# the executed +sql+ statement.
def exec_update(sql, name, binds)
exec_query(sql, name, binds)
......
......@@ -125,7 +125,7 @@ Also in the test directory is the +test/integration+ directory, where integratio
h3. Providing engine functionality
The engine that this guide covers will provide posting and commenting functionality and follows a similar thread to the "Getting Started Guide":getting-started.html, with some new twists.
The engine that this guide covers will provide posting and commenting functionality and follows a similar thread to the "Getting Started Guide":getting_started.html, with some new twists.
h4. Generating a post resource
......
......@@ -152,11 +152,11 @@ $ rails server
TIP: Compiling CoffeeScript to JavaScript requires a JavaScript runtime and the absence of a runtime will give you an +execjs+ error. Usually Mac OS X and Windows come with a JavaScript runtime installed. Rails adds the +therubyracer+ gem to Gemfile in a commented line for new apps and you can uncomment if you need it. +therubyrhino+ is the recommended runtime for JRuby users and is added by default to Gemfile in apps generated under JRuby. You can investigate about all the supported runtimes at "ExecJS":https://github.com/sstephenson/execjs#readme.
This will fire up an instance of a webserver built into Ruby called WEBrick by default. To see your application in action, open a browser window and navigate to "http://localhost:3000":http://localhost:3000. You should see Rails' default information page:
This will fire up an instance of a webserver built into Ruby called WEBrick by default. To see your application in action, open a browser window and navigate to "http://localhost:3000":http://localhost:3000. You should see the Rails default information page:
!images/rails_welcome.png(Welcome Aboard screenshot)!
TIP: To stop the web server, hit Ctrl+C in the terminal window where it's running. In development mode, Rails does not generally require you to stop the server; changes you make in files will be automatically picked up by the server.
TIP: To stop the web server, hit Ctrl+C in the terminal window where it's running. In development mode, Rails does not generally require you to restart the server; changes you make in files will be automatically picked up by the server.
The "Welcome Aboard" page is the _smoke test_ for a new Rails application: it makes sure that you have your software configured correctly enough to serve a page. You can also click on the _About your application’s environment_ link to see a summary of your application's environment.
......
......@@ -497,7 +497,7 @@ and
h4. Using the +change+ Method
The +change+ method removes the need to write both +up+ and +down+ methods in
those cases that Rails know how to revert the changes automatically. Currently,
those cases that Rails knows how to revert the changes automatically. Currently,
the +change+ method supports only these migration definitions:
* +add_column+
......
......@@ -91,13 +91,15 @@ For a freshly generated Rails application, this might produce something like:
<ruby>
use ActionDispatch::Static
use Rack::Lock
use ActiveSupport::Cache::Strategy::LocalCache
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x000000029a0838>
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
use Rack::Sendfile
use ActionDispatch::Reloader
use ActionDispatch::Callbacks
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
......@@ -105,8 +107,9 @@ use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use Rack::MethodOverride
use ActionDispatch::Head
use Rack::ConditionalGet
use Rack::ETag
use ActionDispatch::BestStandardsSupport
run Blog::Application.routes
</ruby>
......@@ -161,18 +164,73 @@ config.middleware.delete(middleware)
h4. Internal Middleware Stack
Much of Action Controller's functionality is implemented as Middlewares. The following table explains the purpose of each of them:
Much of Action Controller's functionality is implemented as Middlewares. The following list explains the purpose of each of them:
|_.Middleware|_.Purpose|
|+Rack::Lock+|Sets <tt>env["rack.multithread"]</tt> flag to +true+ and wraps the application within a Mutex.|
|+ActionController::Failsafe+|Returns HTTP Status +500+ to the client if an exception gets raised while dispatching.|
|+ActiveRecord::QueryCache+|Enables the Active Record query cache.|
|+ActionDispatch::Session::CookieStore+|Uses the cookie based session store.|
|+ActionDispatch::Session::CacheStore+|Uses the Rails cache based session store.|
|+ActionDispatch::Session::MemCacheStore+|Uses the memcached based session store.|
|+ActiveRecord::SessionStore+|Uses the database based session store.|
|+Rack::MethodOverride+|Sets HTTP method based on +_method+ parameter or <tt>env["HTTP_X_HTTP_METHOD_OVERRIDE"]</tt>.|
|+Rack::Head+|Discards the response body if the client sends a +HEAD+ request.|
*+ActionDispatch::Static+*
* Used to serve static assets. Disabled if <tt>config.serve_static_assets</tt> is true.
*+Rack::Lock+*
* Sets <tt>env["rack.multithread"]</tt> flag to +true+ and wraps the application within a Mutex.
*+ActiveSupport::Cache::Strategy::LocalCache::Middleware+*
* Used for memory caching. This cache is not thread safe.
*+Rack::Runtime+*
* Sets an X-Runtime header, containing the time (in seconds) taken to execute the request.
*+Rack::MethodOverride+*
* Allows the method to be overridden if <tt>params[:_method]</tt> is set. This is the middleware which supports the PUT and DELETE HTTP method types.
*+ActionDispatch::RequestId+*
* Makes a unique +X-Request-Id+ header available to the response and enables the <tt>ActionDispatch::Request#uuid</tt> method.
*+Rails::Rack::Logger+*
* Notifies the logs that the request has began. After request is complete, flushes all the logs.
*+ActionDispatch::ShowExceptions+*
* Rescues any exception returned by the application and calls an exceptions app that will wrap it in a format for the end user.
*+ActionDispatch::DebugExceptions+*
* Responsible for logging exceptions and showing a debugging page in case the request is local.
*+ActionDispatch::RemoteIp+*
* Checks for IP spoofing attacks.
*+ActionDispatch::Reloader+*
* Provides prepare and cleanup callbacks, intended to assist with code reloading during development.
*+ActionDispatch::Callbacks+*
* Runs the prepare callbacks before serving the request.
*+ActiveRecord::ConnectionAdapters::ConnectionManagement+*
* Cleans active connections after each request, unless the <tt>rack.test</tt> key in the request environment is set to +true+.
*+ActiveRecord::QueryCache+*
* Enables the Active Record query cache.
*+ActionDispatch::Cookies+*
* Sets cookies for the request.
*+ActionDispatch::Session::CookieStore+*
* Responsible for storing the session in cookies.
*+ActionDispatch::Flash+*
* Sets up the flash keys. Only available if <tt>config.action_controller.session_store</tt> is set to a value.
*+ActionDispatch::ParamsParser+*
* Parses out parameters from the request into <tt>params</tt>.
*+ActionDispatch::Head+*
* Converts HEAD requests to +GET+ requests and serves them as so.
*+Rack::ConditionalGet+*
* Adds support for "Conditional +GET+" so that server responds with nothing if page wasn't changed.
*+Rack::ETag+*
* Adds ETag header on all String bodies. ETags are used to validate cache.
*+ActionDispatch::BestStandardsSupport+*
* Enables “best standards support” so that IE8 renders some elements correctly.
TIP: It's possible to use any of the above middlewares in your custom Rack stack.
......
......@@ -239,7 +239,7 @@ def capify!
#
# === Example
#
# route "root :to => 'welcome'"
# route "root :to => 'welcome#index'"
#
def route(routing_code)
log :route, routing_code
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册