1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Make the guide more friendly

- Changed Rails 3.0 to 3.0+
This commit is contained in:
Jason Noble 2011-11-13 01:35:08 -07:00
parent 9b96f7414e
commit 3e3872b598

View file

@ -747,8 +747,9 @@ while the console is open, type +reload!+ at the console prompt to load them.
h4. Listing All Posts h4. Listing All Posts
The easiest place to start looking at functionality is with the code that lists Let's dive into the Rails code a little deeper to see how the application is
all posts. Open the file +app/controllers/posts_controller.rb+ and look at the showing us the list of Posts. Open the file
+app/controllers/posts_controller.rb+ and look at the
+index+ action: +index+ action:
<ruby> <ruby>
@ -762,9 +763,9 @@ def index
end end
</ruby> </ruby>
+Post.all+ calls the +Post+ model to return all of the posts currently in the +Post.all+ calls the all method on the +Post+ model, which returns all of
database. The result of this call is an array of posts that we store in an the posts currently in the database. The result of this call is an array
instance variable called +@posts+. of Post records that we store in an instance variable called +@posts+.
TIP: For more information on finding records with Active Record, see "Active TIP: For more information on finding records with Active Record, see "Active
Record Query Interface":active_record_querying.html. Record Query Interface":active_record_querying.html.
@ -815,7 +816,7 @@ and links. A few things to note in the view:
NOTE. In previous versions of Rails, you had to use +&lt;%=h post.name %&gt;+ so NOTE. In previous versions of Rails, you had to use +&lt;%=h post.name %&gt;+ so
that any HTML would be escaped before being inserted into the page. In Rails that any HTML would be escaped before being inserted into the page. In Rails
3.0, this is now the default. To get unescaped HTML, you now use +&lt;%= raw 3.0+, this is now the default. To get unescaped HTML, you now use +&lt;%= raw
post.name %&gt;+. post.name %&gt;+.
TIP: For more details on the rendering process, see "Layouts and Rendering in TIP: For more details on the rendering process, see "Layouts and Rendering in
@ -829,9 +830,10 @@ Rails renders a view to the browser, it does so by putting the view's HTML into
a layout's HTML. In previous versions of Rails, the +rails generate scaffold+ a layout's HTML. In previous versions of Rails, the +rails generate scaffold+
command would automatically create a controller specific layout, like command would automatically create a controller specific layout, like
+app/views/layouts/posts.html.erb+, for the posts controller. However this has +app/views/layouts/posts.html.erb+, for the posts controller. However this has
been changed in Rails 3.0. An application specific +layout+ is used for all the been changed in Rails 3.0+. An application specific +layout+ is used for all the
controllers and can be found in +app/views/layouts/application.html.erb+. Open controllers and can be found in +app/views/layouts/application.html.erb+. Open
this layout in your editor and modify the +body+ tag: this layout in your editor and modify the +body+ tag to include the style directive
below:
<erb> <erb>
<!DOCTYPE html> <!DOCTYPE html>