Permalink
Browse files

Convert inline code tags to Markdown

  • Loading branch information...
1 parent 872b7af commit c89c163a0e7df7b29ba33608742eaba09a058090 @sikachu sikachu committed with sikachu Sep 1, 2012
@@ -110,7 +110,7 @@ To send a hash you include the key name inside the brackets:
</form>
```
-When this form is submitted, the value of +params[:client]+ will be <tt>{"name" => "Acme", "phone" => "12345", "address" => {"postcode" => "12345", "city" => "Carrot City"}}</tt>. Note the nested hash in +params[:client][:address]+.
+When this form is submitted, the value of +params[:client]+ will be `{"name" => "Acme", "phone" => "12345", "address" => {"postcode" => "12345", "city" => "Carrot City"}}`. Note the nested hash in +params[:client][:address]+.
Note that the +params+ hash is actually an instance of +HashWithIndifferentAccess+ from Active Support, which acts like a hash that lets you use symbols and strings interchangeably as keys.
@@ -124,7 +124,7 @@ So for example, if you are sending this JSON parameter:
{ "company": { "name": "acme", "address": "123 Carrot Street" } }
```
-You'll get <tt>params[:company]</tt> as <tt>{ :name => "acme", "address" => "123 Carrot Street" }</tt>.
+You'll get `params[:company]` as `{ :name => "acme", "address" => "123 Carrot Street" }`.
Also, if you've turned on +config.wrap_parameters+ in your initializer or calling +wrap_parameters+ in your controller, you can safely omit the root element in the JSON/XML parameter. The parameters will be cloned and wrapped in the key according to your controller's name by default. So the above parameter can be written as:
@@ -423,7 +423,7 @@ class UsersController < ApplicationController
end
```
-Notice that in the above case code is <tt>render :xml => @users</tt> and not <tt>render :xml => @users.to_xml</tt>. That is because if the input is not string then rails automatically invokes +to_xml+ .
+Notice that in the above case code is `render :xml => @users` and not `render :xml => @users.to_xml`. That is because if the input is not string then rails automatically invokes +to_xml+ .
Filters
@@ -712,7 +712,7 @@ end
This will read and stream the file 4kB at the time, avoiding loading the entire file into memory at once. You can turn off streaming with the +:stream+ option or adjust the block size with the +:buffer_size+ option.
-If +:type+ is not specified, it will be guessed from the file extension specified in +:filename+. If the content type is not registered for the extension, <tt>application/octet-stream</tt> will be used.
+If +:type+ is not specified, it will be guessed from the file extension specified in +:filename+. If the content type is not registered for the extension, `application/octet-stream` will be used.
WARNING: Be careful when using data coming from the client (params, cookies, etc.) to locate the file on disk, as this is a security risk that might allow someone to gain access to files they are not meant to see.
@@ -753,7 +753,7 @@ GET /clients/1.pdf
Parameter Filtering
-------------------
-Rails keeps a log file for each environment in the +log+ folder. These are extremely useful when debugging what's actually going on in your application, but in a live application you may not want every bit of information to be stored in the log file. You can filter certain request parameters from your log files by appending them to <tt>config.filter_parameters</tt> in the application configuration. These parameters will be marked [FILTERED] in the log.
+Rails keeps a log file for each environment in the +log+ folder. These are extremely useful when debugging what's actually going on in your application, but in a live application you may not want every bit of information to be stored in the log file. You can filter certain request parameters from your log files by appending them to `config.filter_parameters` in the application configuration. These parameters will be marked [FILTERED] in the log.
```ruby
config.filter_parameters << :password

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -23,7 +23,7 @@ NOTE. Some features of Action View are tied to Active Record, but that doesn't m
Using Action View with Rails
----------------------------
-For each controller there is an associated directory in the <tt>app/views</tt> directory which holds the template files that make up the views associated with that controller. These files are used to display the view that results from each controller action.
+For each controller there is an associated directory in the `app/views` directory which holds the template files that make up the views associated with that controller. These files are used to display the view that results from each controller action.
Let's take a look at what Rails does by default when creating a new resource using the scaffold generator:
@@ -43,7 +43,7 @@ $ rails generate scaffold post
```
There is a naming convention for views in Rails. Typically, the views share their name with the associated controller action, as you can see above.
-For example, the index controller action of the <tt>posts_controller.rb</tt> will use the <tt>index.html.erb</tt> view file in the <tt>app/views/posts</tt> directory.
+For example, the index controller action of the `posts_controller.rb` will use the `index.html.erb` view file in the `app/views/posts` directory.
The complete HTML returned to the client is composed of a combination of this ERB file, a layout template that wraps it, and all the partials that the view may reference. Later on this guide you can find a more detailed documentation of each one of this three components.
Using Action View outside of Rails
@@ -123,9 +123,9 @@ Find below a brief overview of each one of them.
### Templates
-Action View templates can be written in several ways. If the template file has a <tt>.erb</tt> extension then it uses a mixture of ERB (included in Ruby) and HTML. If the template file has a <tt>.builder</tt> extension then a fresh instance of <tt>Builder::XmlMarkup</tt> library is used.
+Action View templates can be written in several ways. If the template file has a `.erb` extension then it uses a mixture of ERB (included in Ruby) and HTML. If the template file has a `.builder` extension then a fresh instance of `Builder::XmlMarkup` library is used.
-Rails supports multiple template systems and uses a file extension to distinguish amongst them. For example, an HTML file using the ERB template system will have <tt>.html.erb</tt> as a file extension.
+Rails supports multiple template systems and uses a file extension to distinguish amongst them. For example, an HTML file using the ERB template system will have `.html.erb` as a file extension.
#### ERB
@@ -151,7 +151,7 @@ To suppress leading and trailing whitespaces, you can use +<%-+ +-%>+ interchang
#### Builder
-Builder templates are a more programmatic alternative to ERB. They are especially useful for generating XML content. An XmlMarkup object named +xml+ is automatically made available to templates with a <tt>.builder</tt> extension.
+Builder templates are a more programmatic alternative to ERB. They are especially useful for generating XML content. An XmlMarkup object named +xml+ is automatically made available to templates with a `.builder` extension.
Here are some basic examples:
@@ -259,25 +259,25 @@ Here, the +_ad_banner.html.erb+ and +_footer.html.erb+ partials could contain co
#### The :as and :object options
-By default <tt>ActionView::Partials::PartialRenderer</tt> has its object in a local variable with the same name as the template. So, given
+By default `ActionView::Partials::PartialRenderer` has its object in a local variable with the same name as the template. So, given
```erb
<%= render :partial => "product" %>
```
-within product we'll get <tt>@product</tt> in the local variable +product+, as if we had written:
+within product we'll get `@product` in the local variable +product+, as if we had written:
```erb
<%= render :partial => "product", :locals => { :product => @product } %>
```
-With the <tt>:as</tt> option we can specify a different name for said local variable. For example, if we wanted it to be +item+ instead of product+ we'd do:
+With the `:as` option we can specify a different name for said local variable. For example, if we wanted it to be +item+ instead of product+ we'd do:
```erb
<%= render :partial => "product", :as => 'item' %>
```
-The <tt>:object</tt> option can be used to directly specify which object is rendered into the partial; useful when the template's object is elsewhere, in a different ivar or in a local variable for instance.
+The `:object` option can be used to directly specify which object is rendered into the partial; useful when the template's object is elsewhere, in a different ivar or in a local variable for instance.
For example, instead of:
@@ -291,7 +291,7 @@ you'd do:
<%= render :partial => "product", :object => @item %>
```
-The <tt>:object</tt> and <tt>:as</tt> options can be used together.
+The `:object` and `:as` options can be used together.
#### Rendering Collections
@@ -1148,7 +1148,7 @@ Sample usage (selecting the associated Author for an instance of Post, +@post+):
collection_select(:post, :author_id, Author.all, :id, :name_with_initial, {:prompt => true})
```
-If <tt>@post.author_id</tt> is 1, this would return:
+If `@post.author_id` is 1, this would return:
```html
<select name="post[author_id]">
@@ -1184,7 +1184,7 @@ Sample usage (selecting the associated Author for an instance of Post, +@post+):
collection_radio_buttons(:post, :author_id, Author.all, :id, :name_with_initial)
```
-If <tt>@post.author_id</tt> is 1, this would return:
+If `@post.author_id` is 1, this would return:
```html
<input id="post_author_id_1" name="post[author_id]" type="radio" value="1" checked="checked" />
@@ -1220,7 +1220,7 @@ Sample usage (selecting the associated Authors for an instance of Post, +@post+)
collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial)
```
-If <tt>@post.author_ids</tt> is <tt><notextile>[1]</notextile></tt>, this would return:
+If `@post.author_ids` is [1], this would return:
```html
<input id="post_author_ids_1" name="post[author_ids][]" type="checkbox" value="1" checked="checked" />
@@ -1320,7 +1320,7 @@ Example:
select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] }, { :include_blank => true })
```
-If <tt>@post.person_id</tt> is 1, this would become:
+If `@post.person_id` is 1, this would become:
```html
<select name="post[person_id]">
Oops, something went wrong.

0 comments on commit c89c163

Please sign in to comment.