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

Ticket #5780 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

[PATCH] collection_singular_ids

Reported by: mschuerig Assigned to: David
Priority: high Milestone: 1.2
Component: ActiveRecord Version: 1.1.1
Severity: normal Keywords:
Cc:

Description

has_many and has_and_belongs_to_many associations each generate collection_singular_ids= methods. What they don't do is generate collection_singular_ids methods that just return the ids of the collected objects. I think they should do this and the patch is dead simple.

Attachments

collection_singular_ids.diff (0.6 kB) - added by mschuerig on 08/13/06 11:10:44.
collection_singular_ids.2.diff (3.0 kB) - added by mschuerig on 10/01/06 18:28:51.
singular_ids and unit tests

Change History

08/13/06 11:10:44 changed by mschuerig

  • attachment collection_singular_ids.diff added.

08/20/06 14:57:18 changed by anonymous

  • version set to 1.1.1.

09/29/06 12:55:04 changed by roderickvd

Inclusion of this patch would be great, because it would allow collection_select() to display the selected values in a habtm association.

(follow-up: ↓ 4 ) 09/29/06 19:26:24 changed by bitsweat

  • status changed from new to closed.
  • resolution set to untested.
  • milestone set to 1.x.

As with #1887, please include unit tests.

10/01/06 18:28:51 changed by mschuerig

  • attachment collection_singular_ids.2.diff added.

singular_ids and unit tests

(in reply to: ↑ 3 ) 10/01/06 18:30:06 changed by mschuerig

  • milestone changed from 1.x to 1.2.

Replying to bitsweat:

As with #1887, please include unit tests.

I've attached a patch including unit tests. It covers the functionality of #1887, too.

10/01/06 18:30:48 changed by mschuerig

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

10/01/06 19:15:52 changed by bitsweat

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

(In [5214]) Association collections have an _ids reader method to match the existing writer for collection_select convenience (e.g. employee.task_ids). The writer method skips blank ids so you can safely do @employee.task_ids = params[:tasks] without checking every time for an empty list or blank values. References #1887, Closes #5780.