diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2011-10-05 18:40:45 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2011-10-05 18:40:45 +0530 |
commit | ea49935a6e0eca8783bc8d1bb46a6c518c073cac (patch) | |
tree | 19df9888950304b223e2a680adb045d9d7a1618f /railties/guides/source | |
parent | 34ed93931dcf688bc4f0f8f5649a44f2f1118a6a (diff) | |
download | rails-ea49935a6e0eca8783bc8d1bb46a6c518c073cac.tar.gz rails-ea49935a6e0eca8783bc8d1bb46a6c518c073cac.tar.bz2 rails-ea49935a6e0eca8783bc8d1bb46a6c518c073cac.zip |
copy editing
Diffstat (limited to 'railties/guides/source')
-rw-r--r-- | railties/guides/source/active_record_validations_callbacks.textile | 4 | ||||
-rw-r--r-- | railties/guides/source/getting_started.textile | 9 | ||||
-rw-r--r-- | railties/guides/source/migrations.textile | 2 |
3 files changed, 6 insertions, 9 deletions
diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index 600681ddd3..2a1e9bfc0c 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -1192,13 +1192,11 @@ h4. Creating Observers For example, imagine a +User+ model where we want to send an email every time a new user is created. Because sending emails is not directly related to our model's purpose, we should create an observer to contain the code implementing this functionality. -Rails can create the initial code of the observers in a simple way. For instance, given a model +User+, the command - <shell> $ rails generate observer User </shell> -generates file +app/models/user_observer.rb+ containing the observer class +UserObserver+: +generates +app/models/user_observer.rb+ containing the observer class +UserObserver+: <ruby> class UserObserver < ActiveRecord::Observer diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile index 6812b6b9fe..bf6104b96b 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -705,7 +705,7 @@ $ rails console TIP: The default console will make changes to your database. You can instead open a console that will roll back any changes you make by using <tt>rails console ---sandbox</tt> . +--sandbox</tt>. After the console loads, you can use it to work with your application's models: @@ -1074,7 +1074,7 @@ In the +update+ action, Rails first uses the +:id+ parameter passed back from the edit view to locate the database record that's being edited. The +update_attributes+ call then takes the +post+ parameter (a hash) from the request and applies it to this record. If all goes well, the user is redirected to the -post's +show+ action. If there are any problems, it's back to the +edit+ action to +post's +show+ action. If there are any problems, it redirects back to the +edit+ action to correct them. h4. Destroying a Post @@ -1115,8 +1115,7 @@ models and controllers. To create the new model, run this command in your terminal: <shell> -$ rails generate model Comment commenter:string body:text \ -> post:references +$ rails generate model Comment commenter:string body:text post:references </shell> This command will generate four files: @@ -1520,7 +1519,7 @@ defined it as an instance variable. h3. Deleting Comments -Another important feature of a blog is being able to delete SPAM comments. To do +Another important feature of a blog is being able to delete spam comments. To do this, we need to implement a link of some sort in the view and a +DELETE+ action in the +CommentsController+. diff --git a/railties/guides/source/migrations.textile b/railties/guides/source/migrations.textile index a73655d130..9c92d567d3 100644 --- a/railties/guides/source/migrations.textile +++ b/railties/guides/source/migrations.textile @@ -658,7 +658,7 @@ In many ways this is exactly what it is. This file is created by inspecting the There is however a trade-off: +db/schema.rb+ cannot express database specific items such as foreign key constraints, triggers, or stored procedures. While in a migration you can execute custom SQL statements, the schema dumper cannot reconstitute those statements from the database. If you are using features like this, then you should set the schema format to +:sql+. -Instead of using Active Record's schema dumper, the database's structure will be dumped using a tool specific the RDBMS of the database (via the +db:structure:dump+ Rake task) into +db/#{Rails.env}_structure.sql+. For example, for the PostgreSQL RDBMS, the +pg_dump+ utility is used. For MySQL, this file will contain the output of +SHOW CREATE TABLE+ for the various tables. Loading these schemas is simply a question of executing the SQL statements they contain. By definition, this will create a perfect copy of the database's structure. Using the +:sql+ schema format will, however, prevent loading the schema into a RDBMS other than the one used to create it. +Instead of using Active Record's schema dumper, the database's structure will be dumped using a tool specific to the database (via the +db:structure:dump+ Rake task) into +db/#{Rails.env}_structure.sql+. For example, for the PostgreSQL RDBMS, the +pg_dump+ utility is used. For MySQL, this file will contain the output of +SHOW CREATE TABLE+ for the various tables. Loading these schemas is simply a question of executing the SQL statements they contain. By definition, this will create a perfect copy of the database's structure. Using the +:sql+ schema format will, however, prevent loading the schema into a RDBMS other than the one used to create it. h4. Schema Dumps and Source Control |