提交 12c0ea95 编写于 作者: X Xavier Noria

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

...@@ -478,7 +478,6 @@ javascript_include_tag :monkey # => ...@@ -478,7 +478,6 @@ javascript_include_tag :monkey # =>
<script type="text/javascript" src="/javascripts/tail.js"></script> <script type="text/javascript" src="/javascripts/tail.js"></script>
</ruby> </ruby>
h5. register_stylesheet_expansion h5. register_stylesheet_expansion
Register one or more stylesheet files to be included when symbol is passed to +stylesheet_link_tag+. This method is typically intended to be called from plugin initialization to register stylesheet files that the plugin installed in +public/stylesheets+. Register one or more stylesheet files to be included when symbol is passed to +stylesheet_link_tag+. This method is typically intended to be called from plugin initialization to register stylesheet files that the plugin installed in +public/stylesheets+.
......
...@@ -168,7 +168,6 @@ Track what was the previous value of the attribute. ...@@ -168,7 +168,6 @@ Track what was the previous value of the attribute.
person.first_name_was #=> "First Name" person.first_name_was #=> "First Name"
</ruby> </ruby>
Track both previous and current value of the changed attribute. Returns an array if changed else returns nil Track both previous and current value of the changed attribute. Returns an array if changed else returns nil
<ruby> <ruby>
#attr_name_change #attr_name_change
......
...@@ -204,7 +204,6 @@ Likewise, once retrieved an Active Record object can be destroyed which removes ...@@ -204,7 +204,6 @@ Likewise, once retrieved an Active Record object can be destroyed which removes
user.destroy user.destroy
</ruby> </ruby>
h3. Validations h3. Validations
Active Record allows you to validate the state of a model before it gets written into the database. There are several methods that you can use to check your models and validate that an attribute value is not empty, is unique and not already in the database, follows a specific format and many more. You can learn more about validations in the "Active Record Validations and Callbacks guide":active_record_validations_callbacks.html#validations-overview. Active Record allows you to validate the state of a model before it gets written into the database. There are several methods that you can use to check your models and validate that an attribute value is not empty, is unique and not already in the database, follows a specific format and many more. You can learn more about validations in the "Active Record Validations and Callbacks guide":active_record_validations_callbacks.html#validations-overview.
......
...@@ -24,16 +24,12 @@ h4. Standard HTML communication vs AJAX ...@@ -24,16 +24,12 @@ h4. Standard HTML communication vs AJAX
How do 'standard' and AJAX requests differ, why does this matter for understanding AJAX on Rails (tie in for *_remote helpers, the next section) How do 'standard' and AJAX requests differ, why does this matter for understanding AJAX on Rails (tie in for *_remote helpers, the next section)
h3. Built-in Rails Helpers h3. Built-in Rails Helpers
Rails' JavaScript framework of choice is "Prototype":http://www.prototypejs.org. Prototype is a generic-purpose JavaScript framework that aims to ease the development of dynamic web applications by offering DOM manipulation, AJAX and other JavaScript functionality ranging from utility functions to object oriented constructs. It is not specifically written for any language, so Rails provides a set of helpers to enable seamless integration of Prototype with your Rails views. Rails' JavaScript framework of choice is "Prototype":http://www.prototypejs.org. Prototype is a generic-purpose JavaScript framework that aims to ease the development of dynamic web applications by offering DOM manipulation, AJAX and other JavaScript functionality ranging from utility functions to object oriented constructs. It is not specifically written for any language, so Rails provides a set of helpers to enable seamless integration of Prototype with your Rails views.
To get access to these helpers, all you have to do is to include the prototype framework in your pages - typically in your master layout, application.html.erb - like so: To get access to these helpers, all you have to do is to include the prototype framework in your pages - typically in your master layout, application.html.erb - like so:
<ruby> <ruby>
javascript_include_tag 'prototype' javascript_include_tag 'prototype'
</ruby> </ruby>
...@@ -59,7 +55,6 @@ link_to_remote "Add to cart", ...@@ -59,7 +55,6 @@ link_to_remote "Add to cart",
</ruby> </ruby>
* The very first parameter, a string, is the text of the link which appears on the page. * The very first parameter, a string, is the text of the link which appears on the page.
* The second parameter, the +options+ hash is the most interesting part as it has the AJAX specific stuff: * The second parameter, the +options+ hash is the most interesting part as it has the AJAX specific stuff:
** *:url* This is the only parameter that is always required to generate the simplest remote link (technically speaking, it is not required, you can pass an empty +options+ hash to +link_to_remote+ - but in this case the URL used for the POST request will be equal to your current URL which is probably not your intention). This URL points to your AJAX action handler. The URL is typically specified by Rails REST view helpers, but you can use the +url_for+ format too. ** *:url* This is the only parameter that is always required to generate the simplest remote link (technically speaking, it is not required, you can pass an empty +options+ hash to +link_to_remote+ - but in this case the URL used for the POST request will be equal to your current URL which is probably not your intention). This URL points to your AJAX action handler. The URL is typically specified by Rails REST view helpers, but you can use the +url_for+ format too.
** *:update* Specifying a DOM id of the element we would like to update. The above example demonstrates the simplest way of accomplishing this - however, we are in trouble if the server responds with an error message because that will be injected into the page too! However, Rails has a solution for this situation: ** *:update* Specifying a DOM id of the element we would like to update. The above example demonstrates the simplest way of accomplishing this - however, we are in trouble if the server responds with an error message because that will be injected into the page too! However, Rails has a solution for this situation:
...@@ -193,7 +188,6 @@ end ...@@ -193,7 +188,6 @@ end
What happens here is that by specifying the Content-Type header variable, we instruct the browser to evaluate the text we are sending over (rather than displaying it as plain text, which is the default behavior). What happens here is that by specifying the Content-Type header variable, we instruct the browser to evaluate the text we are sending over (rather than displaying it as plain text, which is the default behavior).
h3. Testing JavaScript h3. Testing JavaScript
JavaScript testing reminds me the definition of the world 'classic' by Mark Twain: "A classic is something that everybody wants to have read and nobody wants to read." It's similar with JavaScript testing: everyone would like to have it, yet it's not done by too much developers as it is tedious, complicated, there is a proliferation of tools and no consensus/accepted best practices, but we will nevertheless take a stab at it: JavaScript testing reminds me the definition of the world 'classic' by Mark Twain: "A classic is something that everybody wants to have read and nobody wants to read." It's similar with JavaScript testing: everyone would like to have it, yet it's not done by too much developers as it is tedious, complicated, there is a proliferation of tools and no consensus/accepted best practices, but we will nevertheless take a stab at it:
......
...@@ -106,7 +106,6 @@ routes.rb # NO ...@@ -106,7 +106,6 @@ routes.rb # NO
RAILS_ROOT/config/routes.rb # NO RAILS_ROOT/config/routes.rb # NO
</plain> </plain>
h3. Fonts h3. Fonts
h4. Fixed-width Font h4. Fixed-width Font
...@@ -188,4 +187,3 @@ self.class_eval %{ ...@@ -188,4 +187,3 @@ self.class_eval %{
h3. Changelog h3. Changelog
* July 17, 2010: ported from the docrails wiki and revised by "Xavier Noria":credits.html#fxn * July 17, 2010: ported from the docrails wiki and revised by "Xavier Noria":credits.html#fxn
...@@ -27,7 +27,6 @@ config.assets.enabled = false ...@@ -27,7 +27,6 @@ config.assets.enabled = false
It is recommended that you use the defaults for all new apps. It is recommended that you use the defaults for all new apps.
h4. Main Features h4. Main Features
The first feature of the pipeline is to concatenate assets. This is important in a production environment, as it reduces the number of requests that a browser must make to render a web page. While Rails already has a feature to concatenate these types of assetsi -- by placing +:cache => true+ at the end of tags such as +javascript_include_tag+ and +stylesheet_link_tag+ -- many people do not use it. The first feature of the pipeline is to concatenate assets. This is important in a production environment, as it reduces the number of requests that a browser must make to render a web page. While Rails already has a feature to concatenate these types of assetsi -- by placing +:cache => true+ at the end of tags such as +javascript_include_tag+ and +stylesheet_link_tag+ -- many people do not use it.
...@@ -80,7 +79,6 @@ More reading: ...@@ -80,7 +79,6 @@ More reading:
* "Optimize caching":http://code.google.com/speed/page-speed/docs/caching.html * "Optimize caching":http://code.google.com/speed/page-speed/docs/caching.html
* "Revving Filenames: don’t use querystring":http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/ * "Revving Filenames: don’t use querystring":http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
h3. How to Use the Asset Pipeline h3. How to Use the Asset Pipeline
In previous versions of Rails, all assets were located in subdirectories of +public+ such as +images+, +javascripts+ and +stylesheets+. With the asset pipeline, the preferred location for these assets is now the +app/assets+ directory. Files in this directory are served by the Sprockets middleware included in the sprockets gem. In previous versions of Rails, all assets were located in subdirectories of +public+ such as +images+, +javascripts+ and +stylesheets+. With the asset pipeline, the preferred location for these assets is now the +app/assets+ directory. Files in this directory are served by the Sprockets middleware included in the sprockets gem.
...@@ -324,7 +322,6 @@ When files are precompiled, Sprockets also creates a "Gzip":http://en.wikipedia. ...@@ -324,7 +322,6 @@ When files are precompiled, Sprockets also creates a "Gzip":http://en.wikipedia.
TODO: Apache instructions TODO: Apache instructions
h3. Customizing the Pipeline h3. Customizing the Pipeline
...@@ -372,7 +369,6 @@ To enable this, pass a +new+ Object to the config option in +application.rb+: ...@@ -372,7 +369,6 @@ To enable this, pass a +new+ Object to the config option in +application.rb+:
config.assets.css_compressor = Transformer.new config.assets.css_compressor = Transformer.new
</erb> </erb>
h4. Changing the _assets_ Path h4. Changing the _assets_ Path
The public path that Sprockets uses by default is +/assets+. The public path that Sprockets uses by default is +/assets+.
......
...@@ -404,7 +404,6 @@ h3. Further reading ...@@ -404,7 +404,6 @@ h3. Further reading
* "Scaling Rails Screencasts":http://railslab.newrelic.com/scaling-rails * "Scaling Rails Screencasts":http://railslab.newrelic.com/scaling-rails
h3. Changelog h3. Changelog
* Feb 17, 2011: Document 3.0.0 changes to ActiveSupport::Cache * Feb 17, 2011: Document 3.0.0 changes to ActiveSupport::Cache
...@@ -415,4 +414,3 @@ h3. Changelog ...@@ -415,4 +414,3 @@ h3. Changelog
* December 27, 2008: Typo fixes * December 27, 2008: Typo fixes
* November 23, 2008: Incremental updates with various suggested changes and formatting cleanup * November 23, 2008: Incremental updates with various suggested changes and formatting cleanup
* September 15, 2008: Initial version by Aditya Chadha * September 15, 2008: Initial version by Aditya Chadha
...@@ -104,7 +104,6 @@ $ cd railties ...@@ -104,7 +104,6 @@ $ cd railties
$ TEST_DIR=generators rake test $ TEST_DIR=generators rake test
</shell> </shell>
h4. Warnings h4. Warnings
The test suite runs with warnings enabled. Ideally Ruby on Rails should issue no warning, but there may be a few, and also some from third-party libraries. Please ignore (or fix!) them if any, and submit patches that do not issue new warnings. The test suite runs with warnings enabled. Ideally Ruby on Rails should issue no warning, but there may be a few, and also some from third-party libraries. Please ignore (or fix!) them if any, and submit patches that do not issue new warnings.
......
...@@ -342,7 +342,6 @@ output: ...@@ -342,7 +342,6 @@ output:
When parsing POSTed data, Rails will take into account the special +_method+ parameter and acts as if the HTTP method was the one specified inside it ("PUT" in this example). When parsing POSTed data, Rails will take into account the special +_method+ parameter and acts as if the HTTP method was the one specified inside it ("PUT" in this example).
h3. Making Select Boxes with Ease h3. Making Select Boxes with Ease
Select boxes in HTML require a significant amount of markup (one +OPTION+ element for each option to choose from), therefore it makes the most sense for them to be dynamically generated. Select boxes in HTML require a significant amount of markup (one +OPTION+ element for each option to choose from), therefore it makes the most sense for them to be dynamically generated.
......
...@@ -116,7 +116,6 @@ need to know anything about them to continue with this guide. ...@@ -116,7 +116,6 @@ need to know anything about them to continue with this guide.
* Active Support * Active Support
* Railties * Railties
h5. Action Pack h5. Action Pack
Action Pack is a single gem that contains Action Controller, Action View and Action Pack is a single gem that contains Action Controller, Action View and
...@@ -1633,7 +1632,6 @@ Authentication challenge ...@@ -1633,7 +1632,6 @@ Authentication challenge
!images/challenge.png(Basic HTTP Authentication Challenge)! !images/challenge.png(Basic HTTP Authentication Challenge)!
h3. Building a Multi-Model Form h3. Building a Multi-Model Form
Another feature of your average blog is the ability to tag posts. To implement Another feature of your average blog is the ability to tag posts. To implement
......
...@@ -796,7 +796,6 @@ h5. Active Support Methods ...@@ -796,7 +796,6 @@ h5. Active Support Methods
* +Array#to_sentence+ uses format settings as given in the "support.array":https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L30 scope. * +Array#to_sentence+ uses format settings as given in the "support.array":https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml#L30 scope.
h3. Customize your I18n Setup h3. Customize your I18n Setup
h4. Using Different Backends h4. Using Different Backends
......
...@@ -761,7 +761,6 @@ def subclasses ...@@ -761,7 +761,6 @@ def subclasses
end end
</ruby> </ruby>
The +config+ method used at the top of +I18n::Railtie+ is defined on +Rails::Railtie+ and is defined like this: The +config+ method used at the top of +I18n::Railtie+ is defined on +Rails::Railtie+ and is defined like this:
<ruby> <ruby>
...@@ -848,7 +847,7 @@ The +Collection+ class in +railties/lib/rails/initializable.rb+ inherits from +A ...@@ -848,7 +847,7 @@ The +Collection+ class in +railties/lib/rails/initializable.rb+ inherits from +A
The +initializers_chain+ method referenced in the +initializers_for+ method is defined like this: The +initializers_chain+ method referenced in the +initializers_for+ method is defined like this:
<rub> <ruby>
def initializers_chain def initializers_chain
initializers = Collection.new initializers = Collection.new
ancestors.reverse_each do | klass | ancestors.reverse_each do | klass |
......
...@@ -300,6 +300,7 @@ change_table :products do |t| ...@@ -300,6 +300,7 @@ change_table :products do |t|
t.rename :upccode, :upc_code t.rename :upccode, :upc_code
end end
</ruby> </ruby>
removes the +description+ and +name+ columns, creates a +part_number+ column and adds an index on it. Finally it renames the +upccode+ column. This is the same as doing removes the +description+ and +name+ columns, creates a +part_number+ column and adds an index on it. Finally it renames the +upccode+ column. This is the same as doing
<ruby> <ruby>
......
...@@ -386,6 +386,7 @@ ActiveRecord::Base.send :include, Yaffle::ActsAsYaffle ...@@ -386,6 +386,7 @@ ActiveRecord::Base.send :include, Yaffle::ActsAsYaffle
</ruby> </ruby>
Run +rake+ one final time and you should see: Run +rake+ one final time and you should see:
<shell> <shell>
7 tests, 7 assertions, 0 failures, 0 errors, 0 skips 7 tests, 7 assertions, 0 failures, 0 errors, 0 skips
</shell> </shell>
...@@ -426,6 +427,7 @@ require 'yaffle' ...@@ -426,6 +427,7 @@ require 'yaffle'
You can test this by changing to the Rails application that you added the plugin to and starting a rails console. Once in the You can test this by changing to the Rails application that you added the plugin to and starting a rails console. Once in the
console we can check to see if the String has an instance method of to_squawk. console we can check to see if the String has an instance method of to_squawk.
<shell> <shell>
$ cd my_app $ cd my_app
$ rails console $ rails console
......
...@@ -80,7 +80,6 @@ This will also be a good idea, if you modify the structure of an object and old ...@@ -80,7 +80,6 @@ This will also be a good idea, if you modify the structure of an object and old
* _(highlight)Critical data should not be stored in session_. If the user clears his cookies or closes the browser, they will be lost. And with a client-side session storage, the user can read the data. * _(highlight)Critical data should not be stored in session_. If the user clears his cookies or closes the browser, they will be lost. And with a client-side session storage, the user can read the data.
h4. Session Storage h4. Session Storage
-- _Rails provides several storage mechanisms for the session hashes. The most important are ActiveRecordStore and CookieStore._ -- _Rails provides several storage mechanisms for the session hashes. The most important are ActiveRecordStore and CookieStore._
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册