Commit Graph

34226 Commits

Author SHA1 Message Date
HPNeo
96f7ec4537 Add documentation for Hash.from_xml [ci skip] 2012-12-01 14:57:34 -05:00
Florent Guilleux
fb39249f36 Add documentation to AssetTagHelper#image_alt [ci skip] 2012-12-01 14:52:07 -05:00
Carlos Duclos
9bc16d0da2 update AR::Schema docs [ci skip] 2012-12-01 14:49:57 -05:00
Alvaro Pereyra
20e61a6d2b Fixes wrong typo on FormHelper [ci skip] 2012-12-01 14:40:16 -05:00
Alvaro Pereyra
5ab0c5dc22 Cleans documentation from Helpers [ci skip] 2012-12-01 14:38:14 -05:00
Florent Guilleux
8dc4041a9b Revert "Remove trailing whitespaces"
This reverts commit 90c887fa7d0c454b7533e208daefc342dea4d5f3.
2012-12-01 13:22:49 -05:00
Florent Guilleux
90c887fa7d Remove trailing whitespaces 2012-12-01 13:20:39 -05:00
Florent Guilleux
5ff59704f6 Add documentation to TransactionIsolationError [ci skip] 2012-12-01 13:17:36 -05:00
Alvaro Pereyra
cd026d7e8e Improves documentation of Capture helper [ci skip] 2012-12-01 13:17:11 -05:00
Alvaro Pereyra
20b40c86ec Removes :nodoc: tag on AtomFeedHelper [ci skip] 2012-12-01 13:17:11 -05:00
Alvaro Pereyra
33f6209239 Removes unneeded 'Example' tags and whitespaces [ci skip] 2012-12-01 13:17:11 -05:00
Carlos Duclos
ed45782e09 nodoc AD & AV railties classes 2012-12-01 13:12:41 -05:00
HPNeo
c71c8a9623 Remove :nodoc from SanitizeHelper module [ci skip] 2012-12-01 13:03:44 -05:00
Carlos Duclos
abefe32baa nodoc AS::Testing::Pending because is deprecated [ci skip] 2012-12-01 13:00:41 -05:00
Alvaro Pereyra
e166f02b17 Removes :nodoc: label [ci skip] 2012-12-01 12:57:15 -05:00
Alvaro Pereyra
e1c0aa4d4c Improves documentation on favicon_link_tag 2012-12-01 12:53:38 -05:00
Carlos Duclos
a1ffc4a31b remove unneeded Examples tag [ci skip] 2012-12-01 12:53:13 -05:00
HPNeo
2a6cfceefe Update documentation for javascript_include_tag [ci skip] 2012-12-01 12:50:50 -05:00
Vijay Dev
0181c2da97 Merge branch 'master' of github.com:lifo/docrails
Conflicts:
	guides/source/active_record_validations.md
2012-12-01 23:00:47 +05:30
Vijay Dev
9685019c4a copy edits [ci skip] 2012-12-01 22:59:10 +05:30
Florent Guilleux
daab9bba88 Fix Calculations#pluck doc to mention several attributes can be selected [ci skip] 2012-12-01 11:23:02 -05:00
Carlos Antonio da Silva
fb42520252 Fix typo in AS guide [ci skip] 2012-12-01 11:39:09 -02:00
Xavier Noria
0dc1417185 copy-edits the docs of 9ee0ffb 2012-12-01 14:18:25 +01:00
Xavier Noria
60edeceda3 Merge pull request #8246 from urielka/uriel-fixed-8167
Fix #8167 - adding autoloading support for caching
2012-12-01 04:38:36 -08:00
Uriel Katz
9ee0ffb360 Patched Marshal#load to work with constant autoloading (active_support/dependecies.rb) (issue #8167) 2012-12-01 14:00:16 +02:00
Andrew White
005d910624 Make Time.zone.parse to work with JavaScript date strings
Chrome, Safari and Firefox serialize Date objects to strings such
as 'Mon May 28 2012 00:00:00 GMT-0700 (PDT)'. When these strings
are parsed the zone is interpreted as 'GMT-0700' which doesn't
exist in the TzInfo list of timezones.

By taking advantage of the improved date/time handling in 1.9.3
we can use `Date._parse` and the `:offset` value which is parsed
correctly.

Three tests were amended to make them pass:

1.  test_parse_with_old_date

    This needed changing to a different value because the original
    value was before EST was adopted so was being changed to a
    LMT (Local Mean Time) value after the change. It didn't before
    because `DateTime` just has offsets from UTC not timezones.

2.  test_parse_should_not_black_out_system_timezone_dst_jump

    Changed the implementation of this test as the stubs were
    dependent on internal implementation details of the test.
    Confirmed that the modified test still failed when the
    implementation of `parse` was restored to pre-#5571.

3.  test_parse_should_black_out_app_timezone_dst_jump

    Ditto.

Closes #5770.
2012-12-01 11:34:21 +00:00
Santiago Pastorino
0a1c611069 Merge pull request #8387 from claudiob/remove_ar_observer_from_docs
Remove references to AR::Observer from docs
2012-11-30 14:25:52 -08:00
claudiob
20c03e7037 Remove references to AR::Observer from docs
ActiveRecord::Observer was extracted into a separate gem so it
should not be referenced anymore (see https://github.com/rails/rails/commit/ccecab3)
2012-11-30 13:54:03 -08:00
Rafael Mendonça França
76c432f586 Merge pull request #8385 from frodsan/strings_love
hash filters should be accessed with symbols or strings
2012-11-30 08:27:14 -08:00
Francesco Rodriguez
83482256ef hash filters should be accessed with symbols or strings 2012-11-30 11:24:16 -05:00
Jon Leighton
64c53d7ce4 Use separate Relation subclasses for each AR class
At present, ActiveRecord::Delegation compiles delegation methods on a
global basis. The compiled methods apply to all subsequent Relation
instances. This creates several problems:

1) After Post.all.recent has been called, User.all.respond_to?(:recent)
   will be true, even if User.all.recent will actually raise an error due
   to no User.recent method existing. (See #8080.)

2) Depending on the AR class, the delegation should do different things.
   For example, if a Post.zip method exists, then Post.all.zip should call
   it. But this will then result in User.zip being called by a subsequent
   User.all.zip, even if User.zip does not exist, when in fact
   User.all.zip should call User.all.to_a.zip. (There are various
   variants of this problem.)

We are creating these compiled delegations in order to avoid method
missing and to avoid repeating logic on each invocation.

One way of handling these issues is to add additional checks in various
places to ensure we're doing the "right thing". However, this makes the
compiled methods signficantly slower. In which case, there's almost no
point in avoiding method_missing at all. (See #8127 for a proposed
solution which takes this approach.)

This is an alternative approach which involves creating a subclass of
ActiveRecord::Relation for each AR class represented. So, with this
patch, Post.all.class != User.all.class. This means that the delegations
are compiled for and only apply to a single AR class. A compiled method
for Post.all will not be invoked from User.all.

This solves the above issues without incurring significant performance
penalties. It's designed to be relatively seamless, however the downside
is a bit of complexity and potentially confusion for a user who thinks
that Post.all and User.all should be instances of the same class.

Benchmark
---------

require 'active_record'
require 'benchmark/ips'

class Post < ActiveRecord::Base
  establish_connection adapter: 'sqlite3', database: ':memory:'
  connection.create_table :posts

  def self.omg
    :omg
  end
end

relation = Post.all

Benchmark.ips do |r|
  r.report('delegation')   { relation.omg }
  r.report('constructing') { Post.all }
end

Before
------

Calculating -------------------------------------
          delegation      4392 i/100ms
        constructing      4780 i/100ms
-------------------------------------------------
          delegation   144235.9 (±27.7%) i/s -     663192 in   5.038075s
        constructing   182015.5 (±21.2%) i/s -     850840 in   5.005364s

After
-----

Calculating -------------------------------------
          delegation      6677 i/100ms
        constructing      6260 i/100ms
-------------------------------------------------
          delegation   166828.2 (±34.2%) i/s -     754501 in   5.001430s
        constructing   116575.5 (±18.6%) i/s -     563400 in   5.036690s

Comments
--------

Bear in mind that the standard deviations in the above are huge, so we
can't compare the numbers too directly. However, we can conclude that
Relation construction has become a little slower (as we'd expect), but
not by a huge huge amount, and we can still construct a large number of
Relations quite quickly.
2012-11-30 14:06:48 +00:00
Carlos Antonio da Silva
c2be9b0c3e Simplify keys order test for as_json in Active Model 2012-11-30 10:21:24 -02:00
Jon Leighton
68e4442ec7 Fix memory leak in development mode
Keying these hashes by klass causes reloadable classes to never get
freed. Thanks to @thedarkone for pointing this out in
the comments on 221571beb6b4bb7437989bdefaf421f993ab6002.

This doesn't seem to make a massive difference to performance.

Benchmark
---------

require 'active_record'
require 'benchmark/ips'

class Post < ActiveRecord::Base
  establish_connection adapter: 'sqlite3', database: ':memory:'
end

GC.disable

Benchmark.ips(20) do |r|
  r.report { Post.connection }
end

Before
------

Calculating -------------------------------------
                          5632 i/100ms
-------------------------------------------------
                       218671.0 (±1.9%) i/s -    4364800 in  19.969401s

After
-----

Calculating -------------------------------------
                          8743 i/100ms
-------------------------------------------------
                       206525.9 (±17.8%) i/s -    4039266 in  19.992590s
2012-11-30 11:50:11 +00:00
Jon Leighton
c5bdf6c5ae Mark Relation mutators as :nodoc:
These are for internal use only and cannot be relied on as part of the
public API. See discussion on 8c2c60511beaad05a218e73c4918ab89fb1804f0.
2012-11-30 10:29:46 +00:00
Carlos Antonio da Silva
e70bab2a8d Merge pull request #8381 from aderyabin/unnecessary_monkey_patch
Remove outdated monkey patch in mysql tests
2012-11-30 02:28:13 -08:00
Andrey Deryabin
da67d192d2 Revert "Fix annoy warning, when executing testcase."
This reverts commit a3024f81228d7b3b446408114a5dc2a86870cd35.

REASON: Since warning doesn't exist
2012-11-30 12:07:55 +04:00
Rafael Mendonça França
0a6afef374 Merge pull request #8378 from steveklabnik/split_validations_callbacks_guide
Split Validations and Callbacks into separate guides.
2012-11-29 15:06:24 -08:00
Steve Klabnik
b659e00baf Split Validations and Callbacks into separate guides.
Two big features that are only barely related in the same guide. Seems
bad.

I did not check references to these guides yet, so some links may need
to be updated.
2012-11-29 15:03:21 -08:00
Steve Klabnik
d16a1b9e8b Normalize on 'After reading this guide, you will know:'
We have three or four different introduction sentences to the guides.
After this commit, we use the same one everywhere.
2012-11-29 14:25:02 -08:00
Francesco Rodriguez
d168d234e3 nodoc AS::Deprecation::InstanceDelegator class [ci skip] 2012-11-29 13:31:00 -05:00
Francesco Rodriguez
abdfffa213 add documentation to CollectionProxy #length and #size methods [ci skip] 2012-11-29 12:58:31 -05:00
Francesco Rodriguez
61a7a9f38b add documentation to CollectionProxy#empty? 2012-11-29 12:51:31 -05:00
Rafael Mendonça França
f87202f41f Merge pull request #8372 from amparo-luna/gemfile_source_url
Gemfile source url for plugins updated
2012-11-29 08:53:36 -08:00
Amparo Luna
8fc0c98ec1 Gemfile source url for plugins updated 2012-11-29 11:23:32 -05:00
Jeremy Kemper
f2902eb8e0 Move instantiation responsibilities from Inheritance to Persistence. Have Inheritance#discriminate_class_for_record handle STI lookup duties. 2012-11-29 08:56:09 -07:00
Steve Klabnik
97b95c3efb Asset Pipeline: add 'the'
Some guides work without 'the'. For instance, 'Migrations' or
'Form Helpers.' But when we talk about the asset pipeline, we...
always say 'the asset pipeline.' The guide title should reflect this.
2012-11-29 05:34:00 -08:00
Steve Klabnik
362f28deda Command Line: remove 'A Guide to'
It's obvious that this is a guide.
2012-11-29 05:32:12 -08:00
Steve Klabnik
9715d0a30a Migrations: add 'Active Record' to title
Other guides that talk about Active Record specific features include the
name of the library in the title, this one should too for consistency.
2012-11-29 05:30:31 -08:00
Steve Klabnik
e6b8452e58 Fix title of 'form helpers' guide.
They're Rails Guides, so obviously we're talking about Rails Form Helpers.

Also, 'helpers' should be capitalized.
2012-11-29 05:28:52 -08:00
Steve Klabnik
87b5d53e2f Associations: s/A Guide//
It's obvious that this is a guide, and none of the other guides say 'A Guide to'.
2012-11-29 05:27:09 -08:00