Commit Graph

3273 Commits

Author SHA1 Message Date
Xavier Noria
86d5c728fb revises recent commit related to :uniq => true 2010-07-10 00:50:59 +02:00
Neeraj Singh
44b752bea1 expanding on :uniq option in has_many 2010-07-09 16:39:34 -04:00
Xavier Noria
2f04c87855 Merge remote branch 'docrails/master' 2010-07-09 22:08:24 +02:00
José Valim
d9ebc76d70 Refactor previous commits a bit. 2010-07-08 23:45:10 +02:00
David Trasbo
786342e17f Return from ActiveRecord::Base#attributes= unless value is a hash [#4070 state:committed]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 23:24:20 +02:00
Neeraj Singh
1e53404fe9 reset_counter should work with non-traditional belongs_to and polymorphic belongs_to
[#4984 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 23:24:12 +02:00
José Valim
87f64ef05e Improve a bit the code in latest commits. 2010-07-08 22:59:41 +02:00
Neeraj Singh
01629d1804 This patch changes update_attribute implementatino so:
- it will only save the attribute it has been asked to save and not all dirty attributes

- it does not invoke callbacks

- it does change updated_at/on

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 22:43:18 +02:00
Neeraj Singh
690352dce4 consolidating updated_at and updated_on
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 22:41:58 +02:00
Grant Ammons
17650e394f Eager loading :through associations will join the :source model if there are :conditions. [#2362 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 22:36:26 +02:00
Ken Collins
0e9bc23c0e Fix the #using_limitable_reflections? helper to work correctly by not examining the length of an array which contains false/true, hence always passing. [#4869 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 22:34:34 +02:00
Josh Kalderimis
b09fd9ccbb removed an old unused method in AR which removed readonly attributes
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 22:29:08 +02:00
Neeraj Singh
a4f5f0547f removing unused method
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 22:29:08 +02:00
Aaron Patterson
7b0f8534c7 moving parse_sqlite_config to the sqlite3_connection method (where it belongs) [#5071 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-07-08 11:52:38 -07:00
Aaron Patterson
9ac9c35117 removing useless code. [#5070 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-07-08 11:45:42 -07:00
Mislav Marohnić
00f1cd71a9 fix ActiveRecord destroy_all so it returns destroyed records
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-07-08 11:35:17 -07:00
Josh Kalderimis
4b66aab00f mass_assignment_security moved from AR to AMo, and minor test cleanup
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 18:28:45 +02:00
Josh Kalderimis
7c86e8e21b minor changes to mass assignment security patch to bring it in line with rails standards
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 18:28:38 +02:00
Eric Chapweske
606088df3f Mass assignment security refactoring
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-08 18:28:32 +02:00
Xavier Noria
a9587935de copy-edits some docs 2010-07-08 16:53:37 +02:00
Neeraj Singh
4a1207d540 Merge branch 'master' of github.com:lifo/docrails 2010-07-08 10:09:39 -04:00
Neeraj Singh
f6fa6cf611 clarifying how to create non standard primary key 2010-07-08 10:09:20 -04:00
Xavier Noria
64c75d6618 Merge remote branch 'docrails/master' 2010-07-07 12:58:46 +02:00
Xavier Noria
92ff71bb14 documents automatic management of join models in hmt associations, in particular the gotcha that deletion is direct 2010-07-06 17:29:34 +02:00
Neeraj Singh
c1fc59c7ac added more info about << operation in associations 2010-07-06 10:09:54 -04:00
José Valim
a5dda97602 Define a convention for descendants and subclasses.
The former should be symmetric with ancestors and include all children. However, it should not include self since ancestors + descendants should not have duplicated. The latter is symmetric to superclass in the sense it only includes direct children.

By adopting a convention, we expect to have less conflict with other frameworks, as Datamapper. For this moment, to ensure ActiveModel::Validations can be used with Datamapper, we should always call ActiveSupport::DescendantsTracker.descendants(self) internally instead of self.descendants avoiding conflicts.
2010-07-05 13:01:27 +02:00
Neeraj Singh
d10aaefcfd clarifying the comments regarding base_class declaration 2010-07-01 23:06:58 -04:00
José Valim
53b34e8476 Avoid calls to Rails::Application since this is not the official API.
Your application should *always* reference your application const (as Blog::Application) and Rails.application should be used just internally.
2010-07-01 18:43:44 +02:00
James Le Cuirot
f3fedd7f84 Don't remove scheduled destroys when loading an association. [#4642 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-01 01:06:58 +02:00
José Valim
57d750edf7 Make relation a private method. 2010-07-01 00:09:55 +02:00
Xavier Noria
c63cf7bf0d Merge remote branch 'rails/master' 2010-06-30 20:47:26 +02:00
Jeremy Kemper
b07e6fdaa0 Support any mysql-like adapter 2010-06-30 10:38:49 -07:00
Aaron Patterson
3f563f1696 AssociationCollection#create_by_*, find_or_create_by_* work properly now. [#1108 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-06-29 16:13:40 -07:00
Tekin
d7c2e52c6c migrations.rb requires active_support/core_ext/module/aliasing [#5008 state:committed]
Signed-off-by: Xavier Noria <fxn@hashref.com>
2010-06-30 00:53:23 +02:00
J. Pablo Fernández
ff22b9d451 Fixed error when removing an index from a table name values, which is a reserved word, with test.
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-29 21:17:07 +02:00
José Valim
af6ec607fa No need to check if the attribute exists (this is the same behavior as in 2.3) [#4994 state:resolved] and [#5003 state:resolved] 2010-06-29 20:15:32 +02:00
Neeraj Singh
dabf74b495 array subtraction should be faster than iterating over all the elements
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-29 17:57:06 +02:00
Neeraj Singh
e8f88a3298 splitting a really long line into multiple lines which is easy on eyes
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-29 17:57:01 +02:00
David Trasbo
735a4db685 Remove ActiveRecord::Base#class_name [#379 state:committed]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-29 17:54:51 +02:00
José Valim
417125e795 Tidy up deprecation message for with_exclusive_scope. 2010-06-29 17:42:20 +02:00
José Valim
bd1666ad1d Add scoping and unscoped as the syntax to replace the old with_scope and with_exclusive_scope. A few examples:
* with_scope now should be scoping:

Before:

  Comment.with_scope(:find => { :conditions => { :post_id => 1 } }) do
    Comment.first #=> SELECT * FROM comments WHERE post_id = 1
  end

After:

  Comment.where(:post_id => 1).scoping do
    Comment.first #=> SELECT * FROM comments WHERE post_id = 1
  end

* with_exclusive_scope now should be unscoped:

  class Post < ActiveRecord::Base
    default_scope :published => true
  end

  Post.all #=> SELECT * FROM posts WHERE published = true

Before:

  Post.with_exclusive_scope do
    Post.all #=> SELECT * FROM posts
  end

After:

  Post.unscoped do
    Post.all #=> SELECT * FROM posts
  end

Notice you can also use unscoped without a block and it will return an anonymous scope with default_scope values:

  Post.unscoped.all #=> SELECT * FROM posts
2010-06-29 17:18:55 +02:00
Adam Meehan
8fbb5177a7 accepts_nested_attributes_for typo 2010-06-29 13:32:53 +10:00
Santiago Pastorino
093c4eedd0 Remove unneeded reject 2010-06-28 19:14:40 -07:00
Neeraj Singh
40e87ac669 with_exclusive_scope does not work properly if ARel is passed. It does work nicely if hash is passed. Blow up if user is attempting it pass ARel to with_exclusive_scope.
[#3838 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-29 01:18:20 +02:00
Akira Matsuda
4f74d449ee Avoid "no such table" exception when schema migrations table does not exist
[#4990 state:resolved]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-06-27 21:16:34 -07:00
Akira Matsuda
0e5d7c6f64 Use ActiveRecord::Migrator.schema_migrations_table_name instead of hardcoding "schema_migrations"
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-06-27 21:16:09 -07:00
Santiago Pastorino
06b0d6e5cd Add missing require, Base use deprecate method 2010-06-27 20:45:09 -07:00
Kevin Skoglund
8e3e117dbe rake db:migrate:status displays status of migrations [#4947 state:resolved]
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2010-06-28 14:08:40 +12:00
Jeremy Kemper
fb7715b249 Warn that ActiveRecord::Base.reset_subclasses is gone in Rails 3 final. 2010-06-27 18:58:18 -07:00
Xavier Noria
4329f8133f Merge remote branch 'rails/master' 2010-06-28 00:12:15 +02:00