Commit Graph

41678 Commits

Author SHA1 Message Date
Andrew White
d017e92e1d Use a custom route vistor for optimized route generation
Using a Regexp to replace dynamic segments in a path string is fraught
with difficulty and can lead to odd edge cases like #13349. Since we
already have a parsed representation of the path it makes sense to use
that to generate an array of segments that can be used to build an
optimized route's path quickly.

Tests on a simple route (e.g. /posts/:id) show a speedup of 35%:
https://gist.github.com/pixeltrix/8261932

Calculating -------------------------------------
    Current Helper:       5274 i/100ms
    New Helper:           8050 i/100ms
-------------------------------------------------
    Current Helper:     79263.6 (±3.7%) i/s -     395550 in   4.997252s
    New Helper:        153464.5 (±4.9%) i/s -     772800 in   5.047834s

Tests on a more complex route show even an greater performance boost:
https://gist.github.com/pixeltrix/8261957

Calculating -------------------------------------
    Current Helper:       2367 i/100ms
    New Helper:           5382 i/100ms
-------------------------------------------------
    Current Helper:     29506.0 (±3.2%) i/s -     149121 in   5.059294s
    New Helper:         78815.5 (±4.1%) i/s -     398268 in   5.062161s

It also has the added benefit of fixing the edge cases described above.

Fixes #13349
2014-01-05 00:36:25 +00:00
Rafael Mendonça França
339ce7fe9d Merge pull request #13590 from kuldeepaggarwal/fix-date-helper-doc
provide correct example of `datetime_select` helper [ci skip]
2014-01-04 11:21:53 -08:00
Andrew White
3713e43366 Add preview_path to autoload_paths in after_initialize
Only config.autoload_paths is frozen, so add the preview_path
to ActiveSupport::Dependencies.autoload_paths directly in an
after_initialize block. Also protect against a blank preview_path
being added to autoload_paths which can cause a serious slowdown
as Dir[] tries to load all *_preview.rb files under /

Fixes #13372
2014-01-04 18:42:34 +00:00
Kuldeep Aggarwal
e9bfeb0c79 provide correct example of datetime_select helper [ci skip] 2014-01-04 23:59:20 +05:30
Robin Dupret
81066b1158 Merge pull request #13587 from kud86/change_truncate_examples
Fixed truncate documentation. [ci skip]
2014-01-04 04:04:12 -08:00
Konstantin Wlasow
9882ec4a50 Fixed documentation. [ci skip] 2014-01-04 16:18:16 +06:00
Jon Leighton
27bcec28bf Fix mergefail in changelog
The line was duplicated
2014-01-04 09:30:01 +00:00
Jon Leighton
9ea54b2d8e Add deprecation I accidentally missed 2014-01-04 09:29:20 +00:00
Xavier Noria
77d18edf0d Merge pull request #13584 from tjschuck/cannot_cannot_be_can_not
Change all "can not"s to the correct "cannot"
2014-01-03 14:37:04 -08:00
T.J. Schuck
72bb3fc297 Change all "can not"s to the correct "cannot". 2014-01-03 17:02:31 -05:00
Guillermo Iguaran
88c3fd1ef1 Merge pull request #13583 from arthurnn/mem_cache_store_fix
mem_cache_store requires dalli, so only accept dalli/client
2014-01-03 13:43:16 -08:00
Arthur Neves
e7f56a7fe8 Raise if MemCacheStore doenst receive a Dalli obj
:mem_cache_store should receive a list of hosts or a dalli client,
otherwise raise it.
Also adding a changelog.
2014-01-03 16:39:50 -05:00
Robin Dupret
05a81c5fe2 Minor typo fix [ci skip] 2014-01-03 22:33:21 +01:00
Rafael Mendonça França
19b2188e6c Merge pull request #10134 from derikson/collection_proxy_select_with_multiple_args
Change CollectionProxy#select to take the same arguments as ActiveRecord::select
2014-01-03 13:03:19 -08:00
Arthur Neves
98458eea42 mem_cache_store requires dalli, so only accept dalli/client
:mem_cache_store require dalli, rescue Dalli exceptions, and follow Dalli API.
Memcached gem, for instance, doesnt work anymore, as the API are different.

As we already require one client, we should make sure that client works, and not accept others, and if someone wants to use another memcache client they can write their own store adapter.
2014-01-03 15:39:33 -05:00
Rafael Mendonça França
f89266ace8 No need to use fixed size font [ci skip] 2014-01-03 16:42:30 -02:00
Rafael Mendonça França
0cd7b7ba3b Merge pull request #13579 from prathamesh-sonpatki/issue-13552
Fix documentation for end_year option of date_helper [ci skip]
2014-01-03 16:41:33 -02:00
Rafael Mendonça França
96c4bd69c1 Whitespace [ci skip] 2014-01-03 16:33:49 -02:00
Godfrey Chan
788bb40e38 Building new records with enum scopes now works as expected
Previously, this would give an `ArgumentError`:

   class Issue < ActiveRecord::Base
     enum :status, [:open, :finished]
   end

   Issue.open.build # => ArgumentError: '0' is not a valid status
   Issue.open.create # => ArgumentError: '0' is not a valid status

PR #13542 muted the error, but the issue remains. This commit fixes
the issue by allowing the enum value to be written directly via the
setter:

   Issue.new.status = 0 # This now sets status to :open

Assigning a value directly via the setter like this is not part of the
documented public API, so users should not rely on this behavior.

Closes #13530.
2014-01-03 09:31:01 -08:00
Prathamesh Sonpatki
2126c24af6 Fix documentation for end_year option of date_helper [ci skip]
- While editing an existing record, end_year is equal to current selected year plus 5 by default.
- While editing an existing record, start_year is equal to current selected year value minus 5 by default.
- Fixes #13552

Acked-by: Prathamesh Sonpatki <csonpatki@gmail.com>

Acked-by: Prathamesh Sonpatki <csonpatki@gmail.com>
2014-01-03 21:46:21 +05:30
Yves Senn
97e7ca48c1 Deprecate unused symbolized_base_class and symbolized_sti_name.
These methods were only used for the `IdentityMap` which was removed.
They are no longer used internally and should be removed without replacement.

As they were not `:nodoc:`'ed it's better to deprecate them before removal.
2014-01-03 16:31:20 +01:00
Rafael Mendonça França
5aa869861c Merge pull request #13578 from schneems/schneems/database_url-env-default
Use DATABASE_URL by default
2014-01-02 13:02:28 -08:00
schneems
f642b18c0e Use DATABASE_URL by default
See https://github.com/rails/rails/pull/13463#issuecomment-31480799 for full conversation.
2014-01-02 15:00:30 -06:00
Rafael Mendonça França
96288e83c1 Merge pull request #13573 from kuldeepaggarwal/doc-fix-default-values
provide correct information [ci skip]
2014-01-02 11:52:13 -08:00
Jon Leighton
d74043885a Merge pull request #13528 from jonleighton/maintain_test_schema
Automatically maintain test database schema
2014-01-02 10:05:46 -08:00
Kuldeep Aggarwal
ed62584391 provide correct information [ci skip] 2014-01-02 19:28:28 +05:30
Jon Leighton
ff7ab3bc78 Automatically maintain test database schema
* Move check from generated helper to test_help.rb, so that all
  applications can benefit
* Rather than just raising when the test schema has pending migrations,
  try to load in the schema and only raise if there are pending
  migrations afterwards
* Opt out of the check by setting
  config.active_record.maintain_test_schema = false
* Deprecate db:test:* tasks. The test helper is now fully responsible
  for maintaining the test schema, so we don't need rake tasks for this.
  This is also a speed improvement since we're no longer reloading the
  test database on every call to "rake test".
2014-01-02 13:49:00 +00:00
Andrew White
a1d0c0fa3d Reverse 821525e and wrap run_generator call
Ruby 2.1.0 includes the json gem 1.8.1 by default so we need bundler 1.5.1
for `bundle install` to work. To fix this reverse the downgrade to 1.3.5
and wrap the `run_generator` call with a block that resets `THOR_DEBUG`.
2014-01-02 10:06:29 +00:00
Rafael Mendonça França
02d366842c Adding missing require 2014-01-02 00:52:47 -02:00
Rafael Mendonça França
f9d854823f Enable fast_finish in the travis configuration
Since rbx and jruby builds are being allowed to fail lets receive the
build information early enabling this option

See http://about.travis-ci.org/blog/2013-11-27-fast-finishing-builds/
2014-01-02 00:35:51 -02:00
Rafael Mendonça França
55dc36b227 Merge pull request #13569 from schneems/schneems/default-url-sub-key
Move default production database to URL sub key
2014-01-01 17:16:56 -08:00
Andrew White
821525eadc Downgrade bundler until 1.5.2 is available
Bundler sets the THOR_DEBUG environment variable causing Thor to
re-raise exceptions on exit. This is breaking the railties tests
for generators where we are trying to capture error output.

The PR bundler/bundler#2794 fixes this by adding a per-instance
config `:debug` but this has not been released yet so to prevent
errors going unnoticed downgrade bundler to 1.3.5 until such a
time that 1.5.2 has been released.
2014-01-01 23:20:57 +00:00
schneems
9749e0efbf Move default production database to URL sub key
By using the URL sub key in the `database.yml` by default we are exposing the ability to set other attributes such as `pool` or `reap_frequency` without need of modifying the URL to contain non-connection specific information.
2014-01-01 17:48:24 -05:00
Rafael Mendonça França
358abe4524 Merge pull request #13542 from robin850/issue-13530
Fix enum writers when using integers
2014-01-01 19:17:59 -02:00
Rafael Mendonça França
f141919974 Add CHANGELOG entry for #13557 [ci skip] 2014-01-01 19:08:28 -02:00
Rafael Mendonça França
a28f1c2793 Merge pull request #13557 from gmarik/patch-1
Use `Array#wrap` instead `Array()`
2014-01-01 19:04:29 -02:00
Mo Omer
6fc59d38d8 Removed elipsis indicating that the reader should have more code than what is pasted.
[ci skip]
2014-01-01 19:00:57 -02:00
Rafael Mendonça França
0b4905d0d5 Make explicit that the view file need to be created [ci skip]
Closes #13566
2014-01-01 18:57:18 -02:00
Rafael Mendonça França
a7094f5c88 Do not highlight rake routes output as ruby code [ci skip]
Closes #13565
2014-01-01 18:54:55 -02:00
Andrew White
75ad0e642c Don't lazy load the tzinfo library
Lazy loading the tzinfo library doesn't really buy us anything because
the gem is installed as a dependency via the gemspec and if a developer
is using Active Support outside of Rails then they can cherry pick which
files to load anyway.

Fixes #13553
2014-01-01 20:29:56 +00:00
Lauro Caetano
e97d48f17e Merge pull request #13563 from vipulnsward/2014-is-here
2014 is here.
2014-01-01 10:47:24 -08:00
Vipul A M
98cb3e69af update copyright notices to 2014. [ci skip] 2014-01-01 23:59:49 +05:30
Robin Dupret
50060e969b Improve enum documentation
Add a mention about the automatic generation of scopes based on the
allowed values of the field on the enum documentation.
2014-01-01 17:57:38 +01:00
Robin Dupret
7aebcb67b0 Fix the enums writer methods
Previously, the writer methods would simply check whether the passed
argument was the symbol representing the integer value of an enum field.
Therefore, it was not possible to specify the numeric value itself but
the dynamically defined scopes generate where clauses relying on this
kind of values so a chained call to a method like `find_or_initialize_by`
would trigger an `ArgumentError`.

Reference #13530
2014-01-01 17:57:34 +01:00
Rafael Mendonça França
da0463cf5e Improve the tests to not call assert_nothing_raised 2014-01-01 14:15:01 -02:00
Rafael Mendonça França
b94e2dd82c Merge pull request #13550 from vipulnsward/13437-fix
Fix for #13437

Conflicts:
	activerecord/CHANGELOG.md
2014-01-01 14:14:45 -02:00
Rafael Mendonça França
e015f4e2e3 Merge pull request #13556 from yahonda/update_mysql_grant
Update grant statement to address #13549
2014-01-01 07:38:15 -08:00
Rafael Mendonça França
3e1e36b5ad Merge pull request #13561 from robin850/issue-11723
Avoid raising a NameError on FreeBSD using Date
2014-01-01 06:36:43 -08:00
Robin Dupret
224d3a69ac Merge pull request #13559 from JuanitoFatas/action-controller
[ci skip] Add missing flash message in block filter example.
2014-01-01 06:31:05 -08:00
Robin Dupret
afc98eadb8 Avoid raising a NameError on FreeBSD using Date
The Date object has a xmlschema method starting with Ruby 1.9 so we were
assuming that we could safely remove this method and redefine it later
but the call to remove_method throws a NameError on FreeBSD so we should
rely on remove_possible_method instead.

This call is actually needed to avoid warnings when running the test
suite.

Fixes #11723
2014-01-01 15:29:24 +01:00