aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkommissar <cjkenna@gmail.com>2009-07-16 14:52:54 -0400
committerkommissar <cjkenna@gmail.com>2009-07-16 14:52:54 -0400
commit3032795c50bae698b55968fd5a3e80c91485cd0c (patch)
tree96163777c5d4c46f67902109f56d2100778ad20e
parent3e599e6d8e108c7b03b7c4a8055a24f7fa81fa9b (diff)
downloadrails-3032795c50bae698b55968fd5a3e80c91485cd0c.tar.gz
rails-3032795c50bae698b55968fd5a3e80c91485cd0c.tar.bz2
rails-3032795c50bae698b55968fd5a3e80c91485cd0c.zip
minor HTML and formatting fixes
-rw-r--r--railties/guides/source/active_record_querying.textile6
1 files changed, 3 insertions, 3 deletions
diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile
index 3cf536f683..302dad4f1a 100644
--- a/railties/guides/source/active_record_querying.textile
+++ b/railties/guides/source/active_record_querying.textile
@@ -458,7 +458,7 @@ Be careful because this also means you're initializing a model object with only
ActiveRecord::MissingAttributeError: missing attribute: <attribute>
</shell>
-Where +<attribute>+ is the attribute you asked for. The +id+ method will not raise the +ActiveRecord::MissingAttributeError+, so just be careful when working with associations because they need the +id+ method to function properly.
+Where +&lt;attribute&gt;+ is the attribute you asked for. The +id+ method will not raise the +ActiveRecord::MissingAttributeError+, so just be careful when working with associations because they need the +id+ method to function properly.
You can also call SQL functions within the select option. For example, if you would like to only grab a single record per unique value in a certain field by using the +DISTINCT+ function you can do it like this:
@@ -800,12 +800,12 @@ For every field (also known as an attribute) you define in your table, Active Re
You can do +find_last_by_*+ methods too which will find the last record matching your argument.
-You can specify an exclamation point (!) on the end of the dynamic finders to get them to raise an +ActiveRecord::RecordNotFound+ error if they do not return any records, like +Client.find_by_name!("Ryan")+
+You can specify an exclamation point (<tt>!</tt>) on the end of the dynamic finders to get them to raise an +ActiveRecord::RecordNotFound+ error if they do not return any records, like +Client.find_by_name!("Ryan")+
If you want to find both by name and locked, you can chain these finders together by simply typing +and+ between the fields for example +Client.find_by_name_and_locked("Ryan", true)+.
-There's another set of dynamic finders that let you find or create/initialize objects if they aren't found. These work in a similar fashion to the other finders and can be used like +find_or_create_by_name(params[:name])+. Using this will firstly perform a find and then create if the find returns nil. The SQL looks like this for +Client.find_or_create_by_name("Ryan")+:
+There's another set of dynamic finders that let you find or create/initialize objects if they aren't found. These work in a similar fashion to the other finders and can be used like +find_or_create_by_name(params[:name])+. Using this will firstly perform a find and then create if the find returns +nil+. The SQL looks like this for +Client.find_or_create_by_name("Ryan")+:
<sql>
SELECT * FROM clients WHERE (clients.name = 'Ryan') LIMIT 1