Commit Graph

845 Commits

Author SHA1 Message Date
Tarmo Tänav
656f0e7c6c Fix file permissions
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2008-07-31 16:36:23 -05:00
Daniel Guettler
c67713a2fe Use klass.sti_name to make sure associations take store_full_sti_class into account. [#671 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2008-07-22 01:24:47 +01:00
David Dollar
e0750d6a5c Add :accessible option to Associations for allowing mass assignments using hash. [#474 state:resolved]
Allows nested Hashes (i.e. from nested forms) to hydrate the appropriate
ActiveRecord models.

class Post < ActiveRecord::Base
  belongs_to :author,   :accessible => true
  has_many   :comments, :accessible => true
end

post = Post.create({
  :title    => 'Accessible Attributes',
  :author   => { :name => 'David Dollar' },
  :comments => [
    { :body => 'First Post!' },
    { :body => 'Nested Hashes are great!' }
  ]
})

post.comments << { :body => 'Another Comment' }

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2008-07-14 02:53:21 +01:00
Daniel Guettler
84af99e78d Ensure NamedScope#build/create/create!/new works as expected when named scope has hash conditions. [Daniel Guettler, Pratik Naik] [#419 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2008-07-09 14:09:17 +01:00
Brad Greenlee
afa0c7f728 Add support for :primary_key option to has_one as well as has_many so that a key other than the default primary key can be used for the association
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2008-07-06 20:25:10 +02:00
Andre Arko
3351d29970 Add has_many :primary_key option to allow setting the primary key on a has many association
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2008-07-06 20:25:10 +02:00
Pratik Naik
9a25315076 Add extra hash conditions tests for named_scope 2008-06-28 01:57:32 +01:00
Mark Catley
0fd3e4cd2b Fix column collision with named_scope and :joins. [#46 state:resolved] 2008-06-22 19:21:15 -07:00
Tarmo Tänav
1afae84ab2 Fixed that scopes defined with a string name could not be composed 2008-06-22 17:26:00 -07:00
rick
10c581a6de fix merge 2008-06-19 09:59:36 -07:00
Pratik Naik
71bf756ea2 Disable validations for associated belongs_to record by default 2008-06-11 12:39:56 +01:00
Jan De Poorter
7f140bbdda Add :validate option to associations. [#301 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2008-06-11 12:21:57 +01:00
Brandon Keepers
e94e53f9cd fix eager loading with dynamic finders 2008-06-09 12:05:20 -04:00
Michael Koziarski
6277fd9113 Fix faulty tests introduced in 8d0b4fa39 2008-05-24 18:34:59 +12:00
josevalim
8d0b4fa39f Added :select option to has_one and belongs_to, remove unused :order option on belongs_to.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#241 state:resolved]
2008-05-24 17:58:03 +12:00
Rodrigo Kochenburger
bca8751e40 Add ActiveRecord option to store the full class name on STI's type column, allowing one to have STI subclasses in different namespaces [#114]
Signed-off-by: rick <technoweenie@gmail.com>
2008-05-13 15:04:11 -07:00
Xavier Noria
593e21d6ae Dirty attributes aren't cleared if save fails. [#174 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2008-05-12 17:04:17 -07:00
Frederick Cheung
3f0dccbbc7 Ensure hm:t preloading honours reflection options. [#137 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2008-05-11 20:01:14 +01:00
Alex MacCaw
4cc594bd70 Fix validates_uniqueness_of for SQL keywords [#23 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2008-05-11 19:30:03 +01:00
Andreas Neuhaus
bcb090c56b Calling ActiveRecord#inspect on an unloaded association won't wipe the collection [#9 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2008-05-08 00:04:53 -05:00
Frederick Cheung
fbebdb0c09 Ensure correct record is returned when preloading has_one where more than one row exists
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#73 state:closed]
2008-05-06 21:08:52 +12:00
David Heinemeier Hansson
ab4d455d6d Added missing files 2008-05-01 15:03:16 -05:00
David Heinemeier Hansson
6f20efdaf7 Fixed AssociationsPreload such that it doesnt require foreign keys to be integers (fcheung) [#33 state:resolved] 2008-04-30 23:30:50 -05:00
David Heinemeier Hansson
874603ce8d Change tests against all scope to base scope as all is now used as a finder alias 2008-04-30 00:25:52 -05:00
Frederick Cheung
44d2142352 Ensure table names are quoted by the association preloading code.
[#45 state:resolved]

Signed-off-by: Michael Koziarski <michael@koziarski.com>
2008-04-26 12:14:50 +12:00
Josh Peek
4b68982f64 Improve ActiveRecord::Base#table_name unit tests for nested classes. Closes #10289. [scott_willson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9237 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-04-07 19:44:37 +00:00
Pratik Naik
f6b12c11cd Refactor HasManyThroughAssociation to inherit from HasManyAssociation. Association callbacks and <association>_ids= now work with hm:t. Closes #11516 [rubyruy]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9230 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-04-06 00:27:12 +00:00
Jeremy Kemper
ba8e0a846f Ruby 1.9 compat: work around YAML serialization error exposed by validations tests
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9192 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-04-01 06:46:40 +00:00
David Heinemeier Hansson
bdd88810c1 Fixed that has_many :through would ignore the hash conditions (closes #11447) [miloops]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9110 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-28 16:13:57 +00:00
Rick Olson
081ddb6f24 Merge the has_finder gem, renamed as 'named_scope'. Closes #11404 [nkallen]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9084 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-24 02:50:02 +00:00
Jeremy Kemper
5c1be2812d has_one :through supports :source_type. Fix up some tests. References #4756.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9075 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-22 02:20:37 +00:00
Rick Olson
c23c9bd11b Allow association scoping for built/created records if :conditions is specified as a hash. Closes #11393 [miloops]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9068 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-21 18:21:56 +00:00
Rick Olson
273b21faa9 Add has_one :through support, finally. Closes #4756 [thechrisoshow]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9067 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-21 18:09:03 +00:00
Pratik Naik
e117350037 Add :readonly option to HasManyThrough associations. Closes #11156 [miloops]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8989 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-03-07 11:45:07 +00:00
Michael Koziarski
f2546164d6 Make dynamic finders respect the :include on HasManyThrough associations. Closes #10998. [cpytel]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8890 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-02-18 00:14:54 +00:00
Jeremy Kemper
dfa786631b Introduce the :readonly option to all associations. Records from the association cannot be saved. Closes #11084.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8864 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-02-13 06:32:50 +00:00
Jeremy Kemper
78253acb59 Revert r8742: remove has_many with :group option since it has sketchy sql support. Closes #10480.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8790 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-02-03 01:09:58 +00:00
Jeremy Kemper
b1ea27630d Fix has_many :through a polymorphic has_many. Closes #10529 [Aleksey Kondratenko]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8776 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-02-02 03:27:31 +00:00
Jeremy Kemper
be827f9348 Fixed preloading belongs_to associations which reference a custom foreign key. References #9640.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8762 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-31 07:50:15 +00:00
Michael Koziarski
9500ad5fbc Make sure count works on has_many :through associations using :group. Closes #10480 [remvee]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8742 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-27 02:41:55 +00:00
Michael Koziarski
c48f744400 Make sure that belongs_to counter decrements when assigning nil Closes #10804 [jeanmartin]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8735 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-26 06:23:03 +00:00
Jeremy Kemper
16b129a68c belongs_to supports :dependent => :destroy and :delete. Closes #10592.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8675 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-19 05:30:42 +00:00
Jeremy Kemper
355a8ff2cd Introduce preload query strategy for eager :includes. Closes #9640.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8672 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-19 04:19:53 +00:00
Jeremy Kemper
1e70928014 Fix paths
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8661 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-18 07:31:37 +00:00
Jeremy Kemper
43b81d01d0 move assets and models
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8657 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-18 07:27:03 +00:00