Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9051 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

[PATCH] has_many :through associations should render as collections too

Reported by: mathie Assigned to: core
Priority: normal Milestone: 1.x
Component: ActiveRecord Version: edge
Severity: normal Keywords:
Cc: tarmo

Description

Attached is a small patch, with tests, to make:

render :partial => @user.bands

work when the model looks something along the lines of:

class User < ActiveRecord::Base
  has_many :nangs
  has_many :bands, :through => :nangs
end

Previously it was complaining about not being able to find the 'array/_array' partial because it wasn't showing up as a collection.

Attachments

has_many_through_are_collections_too.diff (3.5 kB) - added by mathie on 07/21/07 15:21:48.
has_many :through associations are collections too.
has_many_through_rendered_as_collection_updated.diff (3.5 kB) - added by danger on 11/10/07 15:24:56.
same patch as above - updated to latest trunk

Change History

07/21/07 15:21:48 changed by mathie

  • attachment has_many_through_are_collections_too.diff added.

has_many :through associations are collections too.

07/23/07 23:30:45 changed by lifofifo

Patch looks/works fine.

+1

08/08/07 10:42:11 changed by tarmo

  • cc set to tarmo.

+1

09/14/07 12:53:39 changed by mathie

FWIW, this patch still applies to and works with edge Rails. Do I get to say +1 too? :-)

09/17/07 09:31:30 changed by mathie

  • keywords set to verified.

09/17/07 21:22:27 changed by bitsweat

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to untested.

Looks good, but these tests support sqlite only.

09/18/07 12:57:51 changed by mathie

Oh, how embarrassing. I'll update the tests shortly.

11/10/07 15:24:56 changed by danger

  • attachment has_many_through_rendered_as_collection_updated.diff added.

same patch as above - updated to latest trunk

11/10/07 17:18:13 changed by danger

  • status changed from closed to reopened.
  • resolution deleted.

bitsweat: This patch is for ActionPack, not ActiveRecord. Unless I'm mistaken ActionPack only uses sqlite.

11/12/07 13:23:00 changed by ncr

Would like to see this patch applied.

+1

11/12/07 15:02:15 changed by david

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [8130]) Fixed that has_many :through associations should render as collections too (closes #9051) [mathie/danger]