mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge branch 'master' of github.com:lifo/docrails
This commit is contained in:
commit
6ea48ebfa6
8 changed files with 9 additions and 11 deletions
|
@ -18,7 +18,7 @@ you to present the data from database rows as objects and embellish these data o
|
||||||
with business logic methods. Although most Rails models are backed by a database, models
|
with business logic methods. Although most Rails models are backed by a database, models
|
||||||
can also be ordinary Ruby classes, or Ruby classes that implement a set of interfaces as
|
can also be ordinary Ruby classes, or Ruby classes that implement a set of interfaces as
|
||||||
provided by the ActiveModel module. You can read more about Active Record in its
|
provided by the ActiveModel module. You can read more about Active Record in its
|
||||||
{README}[link:/rails/rails/blob/master/activerecord/README.rdoc].
|
{README}[link:/activerecord/README.rdoc].
|
||||||
|
|
||||||
The Controller layer is responsible for handling incoming HTTP requests and providing a
|
The Controller layer is responsible for handling incoming HTTP requests and providing a
|
||||||
suitable response. Usually this means returning \HTML, but Rails controllers can also
|
suitable response. Usually this means returning \HTML, but Rails controllers can also
|
||||||
|
@ -29,7 +29,7 @@ In Rails, the Controller and View layers are handled together by Action Pack.
|
||||||
These two layers are bundled in a single package due to their heavy interdependence.
|
These two layers are bundled in a single package due to their heavy interdependence.
|
||||||
This is unlike the relationship between Active Record and Action Pack, which are
|
This is unlike the relationship between Active Record and Action Pack, which are
|
||||||
independent. Each of these packages can be used independently outside of Rails. You
|
independent. Each of these packages can be used independently outside of Rails. You
|
||||||
can read more about Action Pack in its {README}[link:/rails/rails/blob/master/actionpack/README.rdoc].
|
can read more about Action Pack in its {README}[link:/actionpack/README.rdoc].
|
||||||
|
|
||||||
== Getting Started
|
== Getting Started
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module ActiveModel
|
module ActiveModel
|
||||||
# == Active \Model Conversions
|
# == Active \Model Conversion
|
||||||
#
|
#
|
||||||
# Handles default conversions: to_model, to_key, to_param, and to_partial_path.
|
# Handles default conversions: to_model, to_key, to_param, and to_partial_path.
|
||||||
#
|
#
|
||||||
|
|
|
@ -130,7 +130,7 @@ A short rundown of some of the major features:
|
||||||
SQLite3[link:classes/ActiveRecord/ConnectionAdapters/SQLite3Adapter.html].
|
SQLite3[link:classes/ActiveRecord/ConnectionAdapters/SQLite3Adapter.html].
|
||||||
|
|
||||||
|
|
||||||
* Logging support for Log4r[http://log4r.sourceforge.net] and Logger[http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc].
|
* Logging support for Log4r[http://log4r.rubyforge.org] and Logger[http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc].
|
||||||
|
|
||||||
ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT)
|
ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT)
|
||||||
ActiveRecord::Base.logger = Log4r::Logger.new('Application Log')
|
ActiveRecord::Base.logger = Log4r::Logger.new('Application Log')
|
||||||
|
|
|
@ -1115,7 +1115,7 @@ module ActiveRecord
|
||||||
# :dependent behavior may affect other callbacks.
|
# :dependent behavior may affect other callbacks.
|
||||||
#
|
#
|
||||||
# * <tt>:destroy</tt> causes all the associated objects to also be destroyed
|
# * <tt>:destroy</tt> causes all the associated objects to also be destroyed
|
||||||
# * <tt>:delete_all</tt> causes all the asssociated objects to be deleted directly from the database (so callbacks will not execute)
|
# * <tt>:delete_all</tt> causes all the associated objects to be deleted directly from the database (so callbacks will not execute)
|
||||||
# * <tt>:nullify</tt> causes the foreign keys to be set to +NULL+. Callbacks are not executed.
|
# * <tt>:nullify</tt> causes the foreign keys to be set to +NULL+. Callbacks are not executed.
|
||||||
# * <tt>:restrict_with_exception</tt> causes an exception to be raised if there are any associated records
|
# * <tt>:restrict_with_exception</tt> causes an exception to be raised if there are any associated records
|
||||||
# * <tt>:restrict_with_error</tt> causes an error to be added to the owner if there are any associated objects
|
# * <tt>:restrict_with_error</tt> causes an error to be added to the owner if there are any associated objects
|
||||||
|
|
|
@ -5,7 +5,7 @@ module ActiveRecord
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
# WhereChain objects act as placeholder for queries in which #where does not have any parameter.
|
# WhereChain objects act as placeholder for queries in which #where does not have any parameter.
|
||||||
# In this case, #where must be chained with either #not, #like, or #not_like to return a new relation.
|
# In this case, #where must be chained with #not to return a new relation.
|
||||||
class WhereChain
|
class WhereChain
|
||||||
def initialize(scope)
|
def initialize(scope)
|
||||||
@scope = scope
|
@scope = scope
|
||||||
|
|
|
@ -845,7 +845,7 @@ Counter cache columns are added to the containing model's list of read-only attr
|
||||||
|
|
||||||
##### `:dependent`
|
##### `:dependent`
|
||||||
|
|
||||||
If you set the `:dependent` option to `:destroy`, then deleting this object will call the `destroy` method on the associated object to delete that object. If you set the `:dependent` option to `:delete`, then deleting this object will delete the associated object _without_ calling its `destroy` method.
|
If you set the `:dependent` option to `:destroy`, then deleting this object will call the `destroy` method on the associated object to delete that object. If you set the `:dependent` option to `:delete`, then deleting this object will delete the associated object _without_ calling its `destroy` method. If you set the `:dependent` option to `:restrict`, then attempting to delete this object will result in a `ActiveRecord::DeleteRestrictionError` if there are any associated objects.
|
||||||
|
|
||||||
WARNING: You should not specify this option on a `belongs_to` association that is connected with a `has_many` association on the other class. Doing so can lead to orphaned records in your database.
|
WARNING: You should not specify this option on a `belongs_to` association that is connected with a `has_many` association on the other class. Doing so can lead to orphaned records in your database.
|
||||||
|
|
||||||
|
|
|
@ -250,8 +250,6 @@ Your name can be added directly after the last word if you don't provide any cod
|
||||||
|
|
||||||
You should not be the only person who looks at the code before you submit it. You know at least one other Rails developer, right? Show them what you’re doing and ask for feedback. Doing this in private before you push a patch out publicly is the “smoke test” for a patch: if you can’t convince one other developer of the beauty of your code, you’re unlikely to convince the core team either.
|
You should not be the only person who looks at the code before you submit it. You know at least one other Rails developer, right? Show them what you’re doing and ask for feedback. Doing this in private before you push a patch out publicly is the “smoke test” for a patch: if you can’t convince one other developer of the beauty of your code, you’re unlikely to convince the core team either.
|
||||||
|
|
||||||
You might want also to check out the [RailsBridge BugMash](http://wiki.railsbridge.org/projects/railsbridge/wiki/BugMash) as a way to get involved in a group effort to improve Rails. This can help you get started and help you check your code when you're writing your first patches.
|
|
||||||
|
|
||||||
### Commit Your Changes
|
### Commit Your Changes
|
||||||
|
|
||||||
When you're happy with the code on your computer, you need to commit the changes to Git:
|
When you're happy with the code on your computer, you need to commit the changes to Git:
|
||||||
|
|
|
@ -208,7 +208,7 @@ create app/assets/stylesheets/welcome.css.scss
|
||||||
|
|
||||||
Most important of these are of course the controller, located at `app/controllers/welcome_controller.rb` and the view, located at `app/views/welcome/index.html.erb`.
|
Most important of these are of course the controller, located at `app/controllers/welcome_controller.rb` and the view, located at `app/views/welcome/index.html.erb`.
|
||||||
|
|
||||||
Open the `app/views/welcome/index.html.erb` file in your text editor and edit it to contain a single line of code:
|
Open the `app/views/welcome/index.html.erb` file in your text editor. Delete all of the existing code in the file, and replace it with the following single line of code:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<h1>Hello, Rails!</h1>
|
<h1>Hello, Rails!</h1>
|
||||||
|
@ -278,7 +278,7 @@ With the route defined, requests can now be made to `/posts/new` in the applicat
|
||||||
|
|
||||||
![Another routing error, uninitialized constant PostsController](images/getting_started/routing_error_no_controller.png)
|
![Another routing error, uninitialized constant PostsController](images/getting_started/routing_error_no_controller.png)
|
||||||
|
|
||||||
This error is happening because this route need a controller to be defined. The route is attempting to find that controller so it can serve the request, but with the controller undefined, it just can't do that. The solution to this particular problem is simple: you need to create a controller called `PostsController`. You can do this by running this command:
|
This error occurs because the route needs to have a controller defined in order to serve the request. The solution to this particular problem is simple: create a controller called `PostsController`. You can do this by running this command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ rails g controller posts
|
$ rails g controller posts
|
||||||
|
|
Loading…
Reference in a new issue