From 4760464efb94297d14d6a35a53da0459ee4d7d7e Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 1 May 2011 15:46:46 +0530 Subject: fix GitHub guides url --- railties/guides/source/contributing_to_ruby_on_rails.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/railties/guides/source/contributing_to_ruby_on_rails.textile b/railties/guides/source/contributing_to_ruby_on_rails.textile index d7090ef675..61a17b6a56 100644 --- a/railties/guides/source/contributing_to_ruby_on_rails.textile +++ b/railties/guides/source/contributing_to_ruby_on_rails.textile @@ -44,7 +44,7 @@ Ruby on Rails uses git for source code control. The "git homepage":http://git-sc * "Everyday Git":http://www.kernel.org/pub/software/scm/git/docs/everyday.html will teach you just enough about git to get by. * The "PeepCode screencast":https://peepcode.com/products/git on git ($9) is easier to follow. -* "GitHub":https://github.com/guides/home offers links to a variety of git resources. +* "GitHub":http://help.github.com offers links to a variety of git resources. * "Pro Git":http://progit.org/book/ is an entire book about git with a Creative Commons license. h4. Clone the Ruby on Rails Repository @@ -232,7 +232,7 @@ You can also help out by examining pull requests that have been submitted to Rub $ git checkout -b testing_branch -Then you can use their remote branch to update your codebase. For example, let's say the github user JohnSmith has forked and pushed to the master branch located at http://github.com/JohnSmith/rails. +Then you can use their remote branch to update your codebase. For example, let's say the GitHub user JohnSmith has forked and pushed to the master branch located at https://github.com/JohnSmith/rails. $ git remote add JohnSmith git://github.com/JohnSmith/rails.git -- cgit v1.2.3 From d1f765644891d6cf6555003de52cb6d58a4da33b Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sun, 1 May 2011 16:15:53 +0530 Subject: remove info about adding verified tag --- railties/guides/source/contributing_to_ruby_on_rails.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/contributing_to_ruby_on_rails.textile b/railties/guides/source/contributing_to_ruby_on_rails.textile index 61a17b6a56..a7d792f88d 100644 --- a/railties/guides/source/contributing_to_ruby_on_rails.textile +++ b/railties/guides/source/contributing_to_ruby_on_rails.textile @@ -252,7 +252,7 @@ Once you're happy that the pull request contains a good change, comment on the G I like the way you've restructured that code in generate_finder_sql, much nicer. The tests look good too. -If your comment simply says "+1", then odds are that other reviewers aren't going to take it too seriously. Show that you took the time to review the patch. Once three people have approved it, add the "verified" tag. This will bring it to the attention of a core team member who will review the changes looking for the same kinds of things. +If your comment simply says "+1", then odds are that other reviewers aren't going to take it too seriously. h3. Contributing to the Rails Documentation -- cgit v1.2.3 From ca608b8c9c9bc47160f0413ce02d3315f89ef537 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Sun, 1 May 2011 12:28:16 -0300 Subject: Bring this back on the contributing guide. --- railties/guides/source/contributing_to_ruby_on_rails.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/contributing_to_ruby_on_rails.textile b/railties/guides/source/contributing_to_ruby_on_rails.textile index a7d792f88d..cb09b180a2 100644 --- a/railties/guides/source/contributing_to_ruby_on_rails.textile +++ b/railties/guides/source/contributing_to_ruby_on_rails.textile @@ -252,7 +252,7 @@ Once you're happy that the pull request contains a good change, comment on the G I like the way you've restructured that code in generate_finder_sql, much nicer. The tests look good too. -If your comment simply says "+1", then odds are that other reviewers aren't going to take it too seriously. +If your comment simply says "+1", then odds are that other reviewers aren't going to take it too seriously. Show that you took the time to review the pull request. h3. Contributing to the Rails Documentation -- cgit v1.2.3 From 31110c50e499067ccb8b4c0693d81f4153e6e155 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Sun, 1 May 2011 15:33:27 -0300 Subject: Fix punctuation errors. --- activeresource/lib/active_resource/validations.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/activeresource/lib/active_resource/validations.rb b/activeresource/lib/active_resource/validations.rb index a373e53f11..ca265d053e 100644 --- a/activeresource/lib/active_resource/validations.rb +++ b/activeresource/lib/active_resource/validations.rb @@ -8,9 +8,9 @@ module ActiveResource # Active Resource validation is reported to and from this object, which is used by Base#save # to determine whether the object in a valid state to be saved. See usage example in Validations. class Errors < ActiveModel::Errors - # Grabs errors from an array of messages (like ActiveRecord::Validations) + # Grabs errors from an array of messages (like ActiveRecord::Validations). # The second parameter directs the errors cache to be cleared (default) - # or not (by passing true) + # or not (by passing true). def from_array(messages, save_cache = false) clear unless save_cache humanized_attributes = Hash[@base.attributes.keys.map { |attr_name| [attr_name.humanize, attr_name] }] @@ -73,7 +73,7 @@ module ActiveResource # clear the remote validations so they don't interfere with the local # ones. Otherwise we get an endless loop and can never change the - # fields so as to make the resource valid + # fields so as to make the resource valid. @remote_errors = nil if perform_validation && valid? || !perform_validation save_without_validation @@ -84,7 +84,7 @@ module ActiveResource rescue ResourceInvalid => error # cache the remote errors because every call to valid? clears # all errors. We must keep a copy to add these back after local - # validations + # validations. @remote_errors = error load_remote_errors(@remote_errors, true) false @@ -92,7 +92,7 @@ module ActiveResource # Loads the set of remote errors into the object's Errors based on the - # content-type of the error-block received + # content-type of the error-block received. def load_remote_errors(remote_errors, save_cache = false ) #:nodoc: case self.class.format when ActiveResource::Formats[:xml] -- cgit v1.2.3 From 24724288812c8c8892536d0519c019d8a3aea8d1 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Sun, 1 May 2011 15:46:01 -0300 Subject: Remove extra whitespaces. --- activeresource/lib/active_resource/http_mock.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/activeresource/lib/active_resource/http_mock.rb b/activeresource/lib/active_resource/http_mock.rb index e085a05f6d..02b1192d7e 100644 --- a/activeresource/lib/active_resource/http_mock.rb +++ b/activeresource/lib/active_resource/http_mock.rb @@ -9,8 +9,8 @@ module ActiveResource # requests. # # To test your Active Resource model, you simply call the ActiveResource::HttpMock.respond_to - # method with an attached block. The block declares a set of URIs with expected input, and the output - # each request should return. The passed in block has any number of entries in the following generalized + # method with an attached block. The block declares a set of URIs with expected input, and the output + # each request should return. The passed in block has any number of entries in the following generalized # format: # # mock.http_method(path, request_headers = {}, body = nil, status = 200, response_headers = {}) @@ -29,7 +29,7 @@ module ActiveResource # request_headers listed above. # # In order for a mock to deliver its content, the incoming request must match by the http_method, - # +path+ and request_headers. If no match is found an InvalidRequestError exception + # +path+ and request_headers. If no match is found an +InvalidRequestError+ exception # will be raised showing you what request it could not find a response for and also what requests and response # pairs have been recorded so you can create a new mock for that request. # @@ -80,7 +80,7 @@ module ActiveResource class << self - # Returns an array of all request objects that have been sent to the mock. You can use this to check + # Returns an array of all request objects that have been sent to the mock. You can use this to check # if your model actually sent an HTTP request. # # ==== Example @@ -105,7 +105,7 @@ module ActiveResource end # Returns the list of requests and their mocked responses. Look up a - # response for a request using responses.assoc(request). + # response for a request using responses.assoc(request). def responses @@responses ||= [] end -- cgit v1.2.3 From 825dae1f0b32bac0e5afde61578534d1a3df8b7b Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Sun, 1 May 2011 15:50:53 -0300 Subject: Documented ActiveResource#observing --- activeresource/lib/active_resource/observing.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/activeresource/lib/active_resource/observing.rb b/activeresource/lib/active_resource/observing.rb index 3c74d49c80..1bfceb8dc8 100644 --- a/activeresource/lib/active_resource/observing.rb +++ b/activeresource/lib/active_resource/observing.rb @@ -5,6 +5,14 @@ module ActiveResource included do %w( create save update destroy ).each do |method| + # def create_with_notifications(*args, &block) + # notify_observers(:before_create) + # if result = create_without_notifications(*args, &block) + # notify_observers(:after_create) + # end + # result + # end + # alias_method_chain(create, :notifications) class_eval(<<-EOS, __FILE__, __LINE__ + 1) def #{method}_with_notifications(*args, &block) notify_observers(:before_#{method}) -- cgit v1.2.3 From 06b91381889fcbd32018ab045b1795ada8718cad Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Sun, 1 May 2011 15:59:27 -0300 Subject: Added some docs on ActiveResource::HttpMock --- activeresource/lib/active_resource/http_mock.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/activeresource/lib/active_resource/http_mock.rb b/activeresource/lib/active_resource/http_mock.rb index 02b1192d7e..3bfd536b29 100644 --- a/activeresource/lib/active_resource/http_mock.rb +++ b/activeresource/lib/active_resource/http_mock.rb @@ -299,6 +299,8 @@ module ActiveResource end end + # Returns true if code is 2xx, + # false otherwise. def success? code.in?(200..299) end @@ -311,6 +313,8 @@ module ActiveResource headers[key] = value end + # Returns true if the other is a Response with an equal body, equal message + # and equal headers. Otherwise it returns false. def ==(other) if (other.is_a?(Response)) other.body == body && other.message == message && other.headers == headers -- cgit v1.2.3 From 9fa080e703362876b5afe9a7627bf3ffb6fa131e Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Mon, 2 May 2011 00:15:36 -0300 Subject: Update security guide with #new and #create respect mass-assignment --- railties/guides/source/security.textile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/railties/guides/source/security.textile b/railties/guides/source/security.textile index f87ffdb20d..40fe764ae9 100644 --- a/railties/guides/source/security.textile +++ b/railties/guides/source/security.textile @@ -441,7 +441,7 @@ params[:user] # => {:name => "ow3ned", :admin => true} @user.admin # => true -When assigning attributes in Active Record using +new+, +attributes=+, or +update_attributes+ the :default scope will be used. To assign attributes using different scopes you should use +assign_attributes+ which accepts an optional :as options parameter. If no :as option is provided then the :default scope will be used. You can also bypass mass-assignment security by using the +:without_protection+ option. Here is an example: +When assigning attributes in Active Record using +attributes=+, or +update_attributes+ the :default scope will be used. To assign attributes using different scopes you should use +assign_attributes+ which accepts an optional :as options parameter. If no :as option is provided then the :default scope will be used. You can also bypass mass-assignment security by using the +:without_protection+ option. Here is an example: @user = User.new @@ -459,7 +459,19 @@ When assigning attributes in Active Record using +new+, +attributes=+, or +updat @user.is_admin # => true -A more paranoid technique to protect your whole project would be to enforce that all models define their accessible attributes. This can be easily achieved with a very simple application config option of: +In a similar way, +new+, +create+ and create! methods respect mass-assignment security and accepts either +:as+ or +:without_protection+ options. For example: + + +@user = User.new({ :name => 'Sebastian', :is_admin => true }, :as => :admin) +@user.name # => Sebastian +@user.is_admin # => true + +@user = User.create({ :name => 'Sebastian', :is_admin => true }, :without_protection => true) +@user.name # => Sebastian +@user.is_admin # => true + + +A more paranoid technique to protect your whole project would be to enforce that all models define their accessible attributes. This can be easily achieved with a very simple application config option of: config.active_record.whitelist_attributes = true -- cgit v1.2.3 From 527036ebd106fdb4d5890f00f2576a99c57b1514 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Mon, 2 May 2011 17:31:00 +0530 Subject: removed verify docs (feature removed in Rails3) --- .../source/action_controller_overview.textile | 39 ---------------------- 1 file changed, 39 deletions(-) diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile index f8b586c151..3a1a4ee66e 100644 --- a/railties/guides/source/action_controller_overview.textile +++ b/railties/guides/source/action_controller_overview.textile @@ -488,45 +488,6 @@ end Again, this is not an ideal example for this filter, because it's not run in the scope of the controller but gets the controller passed as an argument. The filter class has a class method +filter+ which gets run before or after the action, depending on if it's a before or after filter. Classes used as around filters can also use the same +filter+ method, which will get run in the same way. The method must +yield+ to execute the action. Alternatively, it can have both a +before+ and an +after+ method that are run before and after the action. -h3. Verification - -Verifications make sure certain criteria are met in order for a controller or action to run. They can specify that a certain key (or several keys in the form of an array) is present in the +params+, +session+ or +flash+ hashes or that a certain HTTP method was used or that the request was made using +XMLHttpRequest+ (Ajax). The default action taken when these criteria are not met is to render a 400 Bad Request response, but you can customize this by specifying a redirect URL or rendering something else and you can also add flash messages and HTTP headers to the response. - -Here's an example of using verification to make sure the user supplies a username and a password in order to log in: - - -class LoginsController < ApplicationController - verify :params => [:username, :password], - :render => {:action => "new"}, - :add_flash => { - :error => "Username and password required to log in" - } - - def create - @user = User.authenticate(params[:username], params[:password]) - if @user - flash[:notice] = "You're logged in" - redirect_to root_url - else - render :action => "new" - end - end -end - - -Now the +create+ action won't run unless the "username" and "password" parameters are present, and if they're not, an error message will be added to the flash and the +new+ action will be rendered. But there's something rather important missing from the verification above: It will be used for *every* action in LoginsController, which is not what we want. You can limit which actions it will be used for with the +:only+ and +:except+ options just like a filter: - - -class LoginsController < ApplicationController - verify :params => [:username, :password], - :render => {:action => "new"}, - :add_flash => { - :error => "Username and password required to log in" - }, - :only => :create # Run only for the "create" action -end - - h3. Request Forgery Protection Cross-site request forgery is a type of attack in which a site tricks a user into making requests on another site, possibly adding, modifying or deleting data on that site without the user's knowledge or permission. -- cgit v1.2.3 From 09edaf49646c14b6162726c1fb2bc0e980c3962f Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Mon, 2 May 2011 17:39:46 +0530 Subject: removed reference to verify method --- railties/guides/source/security.textile | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/railties/guides/source/security.textile b/railties/guides/source/security.textile index 40fe764ae9..8c408ec06b 100644 --- a/railties/guides/source/security.textile +++ b/railties/guides/source/security.textile @@ -211,15 +211,7 @@ The HTTP protocol basically provides two main types of requests - GET and POST ( If your web application is RESTful, you might be used to additional HTTP verbs, such as PUT or DELETE. Most of today‘s web browsers, however do not support them - only GET and POST. Rails uses a hidden +_method+ field to handle this barrier. -_(highlight)The verify method in a controller can make sure that specific actions may not be used over GET_. Here is an example to verify the use of the transfer action over POST. If the action comes in using any other verb, it redirects to the list action. - - -verify :method => :post, :only => [:transfer], :redirect_to => {:action => :list} - - -With this precaution, the attack from above will not work, because the browser sends a GET request for images, which will not be accepted by the web application. - -But this was only the first step, because _(highlight)POST requests can be sent automatically, too_. Here is an example for a link which displays www.harmless.com as destination in the browser's status bar. In fact it dynamically creates a new form that sends a POST request. +_(highlight)POST requests can be sent automatically, too_. Here is an example for a link which displays www.harmless.com as destination in the browser's status bar. In fact it dynamically creates a new form that sends a POST request. where, includes, and joins operations in Relation, which are merged. # # joins operations are uniqued so multiple scopes can join in the same table without table aliasing - # problems. If you need to join multiple tables, but still want one of the tables to be uniqued, use the + # problems. If you need to join multiple tables, but still want one of the tables to be uniqued, use the # array of strings format for your joins. # # class Article < ActiveRecord::Base @@ -1400,7 +1400,7 @@ end end.join(', ') end - # Accepts an array of conditions. The array has each value + # Accepts an array of conditions. The array has each value # sanitized and interpolated into the SQL statement. # ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'" def sanitize_sql_array(ary) @@ -1508,7 +1508,7 @@ end end # Populate +coder+ with attributes about this record that should be - # serialized. The structure of +coder+ defined in this method is + # serialized. The structure of +coder+ defined in this method is # guaranteed to match the structure of +coder+ passed to the +init_with+ # method. # @@ -1523,8 +1523,8 @@ end coder['attributes'] = attributes end - # Initialize an empty model object from +coder+. +coder+ must contain - # the attributes necessary for initializing an empty model object. For + # Initialize an empty model object from +coder+. +coder+ must contain + # the attributes necessary for initializing an empty model object. For # example: # # class Post < ActiveRecord::Base -- cgit v1.2.3 From d53c2e4952f9dc938648b791f1f3c697f34ff922 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Mon, 2 May 2011 20:30:31 -0300 Subject: fixed-fonts on SchemaDefinitions --- .../connection_adapters/abstract/schema_definitions.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index 7ac48c6646..2f747e77a1 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -204,7 +204,7 @@ module ActiveRecord # end # # There's a short-hand method for each of the type values declared at the top. And then there's - # TableDefinition#timestamps that'll add created_at and +updated_at+ as datetimes. + # TableDefinition#timestamps that'll add +created_at+ and +updated_at+ as datetimes. # # TableDefinition#references will add an appropriately-named _id column, plus a corresponding _type # column if the :polymorphic option is supplied. If :polymorphic is a hash of @@ -351,7 +351,7 @@ module ActiveRecord @base.index_exists?(@table_name, column_name, options) end - # Adds timestamps (created_at and updated_at) columns to the table. See SchemaStatements#add_timestamps + # Adds timestamps (+created_at+ and +updated_at+) columns to the table. See SchemaStatements#add_timestamps # ===== Example # t.timestamps def timestamps @@ -398,7 +398,7 @@ module ActiveRecord @base.remove_index(@table_name, options) end - # Removes the timestamp columns (created_at and updated_at) from the table. + # Removes the timestamp columns (+created_at+ and +updated_at+) from the table. # ===== Example # t.remove_timestamps def remove_timestamps -- cgit v1.2.3 From 3b795c12d763803c53a3eabe4b50ad6bbb98df57 Mon Sep 17 00:00:00 2001 From: backspace Date: Tue, 3 May 2011 15:41:11 -0500 Subject: Fix typo in Factory Girl description --- railties/guides/source/testing.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/testing.textile b/railties/guides/source/testing.textile index 9b1ef22b97..efa2bbdca6 100644 --- a/railties/guides/source/testing.textile +++ b/railties/guides/source/testing.textile @@ -941,7 +941,7 @@ h3. Other Testing Approaches The built-in +test/unit+ based testing is not the only way to test Rails applications. Rails developers have come up with a wide variety of other approaches and aids for testing, including: * "NullDB":http://avdi.org/projects/nulldb/, a way to speed up testing by avoiding database use. -* "Factory Girl":https://github.com/thoughtbot/factory_girl/tree/master, as replacement for fixtures. +* "Factory Girl":https://github.com/thoughtbot/factory_girl/tree/master, a replacement for fixtures. * "Machinist":https://github.com/notahat/machinist/tree/master, another replacement for fixtures. * "Shoulda":http://www.thoughtbot.com/projects/shoulda, an extension to +test/unit+ with additional helpers, macros, and assertions. * "RSpec":http://rspec.info/, a behavior-driven development framework -- cgit v1.2.3 From f04906249716718de88ed093146fcd9816a6e21e Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Tue, 3 May 2011 21:11:17 -0300 Subject: Fixes on schema_definitions docs --- .../connection_adapters/abstract/schema_definitions.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index 2f747e77a1..70a8f6bb58 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -104,7 +104,7 @@ module ActiveRecord # Available options are (none of these exists by default): # * :limit - # Requests a maximum column length. This is number of characters for :string and - # :text columns and number of bytes for :binary and :integer columns. + # :text columns and number of bytes for :binary and :integer columns. # * :default - # The column's default value. Use nil for NULL. # * :null - @@ -153,7 +153,7 @@ module ActiveRecord # This method returns self. # # == Examples - # # Assuming td is an instance of TableDefinition + # # Assuming +td+ is an instance of TableDefinition # td.column(:granted, :boolean) # # granted BOOLEAN # @@ -412,7 +412,7 @@ module ActiveRecord @base.rename_column(@table_name, column_name, new_column_name) end - # Adds a reference. Optionally adds a +type+ column. + # Adds a reference. Optionally adds a +type+ column, if :polymorphic option is provided. # references and belongs_to are acceptable. # ===== Examples # t.references(:goat) -- cgit v1.2.3 From fab9bb77bf1ee57e4cbb4d2c7d8cf474edc42709 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Tue, 3 May 2011 21:25:38 -0300 Subject: Added #recreate_database docs --- activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 862ce852e6..5545a94859 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -517,6 +517,8 @@ module ActiveRecord end.join("") end + # Drops the database specified on the +name+ attribute + # and creates it again using the provided +options+. def recreate_database(name, options = {}) #:nodoc: drop_database(name) create_database(name, options) -- cgit v1.2.3 From 0ee2513356404f47f6d1ba1248e8d70421cef578 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Tue, 3 May 2011 21:26:02 -0300 Subject: Improves Mysql2 adapter docs --- .../lib/active_record/connection_adapters/mysql2_adapter.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb index d3a054c29b..2f64f2b077 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -5,6 +5,7 @@ require 'mysql2' module ActiveRecord class Base + # Establishes a connection to the database that's used by all Active Record objects. def self.mysql2_connection(config) config[:username] = 'root' if config[:username].nil? @@ -213,6 +214,8 @@ module ActiveRecord false end + # Disconnects from the database if already connected. + # Otherwise, this method does nothing. def disconnect! unless @connection.nil? @connection.close @@ -368,6 +371,8 @@ module ActiveRecord end end + # Drops the database specified on the +name+ attribute + # and creates it again using the provided +options+. def recreate_database(name, options = {}) drop_database(name) create_database(name, options) @@ -538,6 +543,7 @@ module ActiveRecord end end + # SHOW VARIABLES LIKE 'name'. def show_variable(name) variables = select_all("SHOW VARIABLES LIKE '#{name}'") variables.first['Value'] unless variables.empty? -- cgit v1.2.3 From 24586edae2f808c256a9e3d5e0bf09236358ee7e Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Tue, 3 May 2011 21:38:19 -0300 Subject: Remove extra whitespaces --- .../connection_adapters/abstract_adapter.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 468a2b106b..65024d76f8 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -46,34 +46,34 @@ module ActiveRecord @instrumenter = ActiveSupport::Notifications.instrumenter end - # Returns the human-readable name of the adapter. Use mixed case - one + # Returns the human-readable name of the adapter. Use mixed case - one # can always use downcase if needed. def adapter_name 'Abstract' end - # Does this adapter support migrations? Backend specific, as the + # Does this adapter support migrations? Backend specific, as the # abstract adapter always returns +false+. def supports_migrations? false end # Can this adapter determine the primary key for tables not attached - # to an Active Record class, such as join tables? Backend specific, as + # to an Active Record class, such as join tables? Backend specific, as # the abstract adapter always returns +false+. def supports_primary_key? false end - # Does this adapter support using DISTINCT within COUNT? This is +true+ + # Does this adapter support using DISTINCT within COUNT? This is +true+ # for all adapters except sqlite. def supports_count_distinct? true end - # Does this adapter support DDL rollbacks in transactions? That is, would - # CREATE TABLE or ALTER TABLE get rolled back by a transaction? PostgreSQL, - # SQL Server, and others support this. MySQL and others do not. + # Does this adapter support DDL rollbacks in transactions? That is, would + # CREATE TABLE or ALTER TABLE get rolled back by a transaction? PostgreSQL, + # SQL Server, and others support this. MySQL and others do not. def supports_ddl_transactions? false end @@ -89,7 +89,7 @@ module ActiveRecord end # Should primary key values be selected from their corresponding - # sequence before the insert statement? If true, next_sequence_value + # sequence before the insert statement? If true, next_sequence_value # is called before each insert to set the record's primary key. # This is false for all adapters but Firebird. def prefetch_primary_key?(table_name = nil) @@ -149,7 +149,7 @@ module ActiveRecord ### # Clear any caching the database adapter may be doing, for example - # clearing the prepared statement cache. This is database specific. + # clearing the prepared statement cache. This is database specific. def clear_cache! # this should be overridden by concrete adapters end -- cgit v1.2.3