FYI: undefined method `map!' for #<[model]::ActiveRecord_Associations_CollectionProxy

30 views
Skip to first unread message

Tim Griffin

unread,
Jan 20, 2016, 4:21:20 PM1/20/16
to Hobo Users
Hi all;

I'm posting this here not only so I can Google myself later, but because it was an interesting little problem I hit when asking Hobo's <table-plus> tag to render a particular collection I had. 

For this example, I had two models: "Entity" and "Parties". 

An Entity has_many Parties. 

For the Entity, though, I also created a named collection of parties called "directors":

  has_many :directors, class_name: 'Party', :inverse_of => :entity

When I asked <table-plus> to render my collection of Directors:

   with="&this.directors" 

ActiveRecord balked with:

   undefined method `map!' for #<Party::ActiveRecord_Associations_CollectionProxy

The quick fix was:

   with="&this.directors.all" 

to force the collection to be loaded immediately. 

And now I know a little about CollectionProxies
Tim



Ibon Castilla

unread,
Jan 20, 2016, 4:31:44 PM1/20/16
to hobo...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks for sharing! :)

Best regards, Ibon.

Abrazo, Ibon.

Usa Software Libre, tus úlceras te lo agradecerán
Realizado con Software Libre.
- --
GPG public key at http://sinanimodelucro.net/ibon_gmail.asc
Finderprint: 1761 59B9 6DE6 0402 31B9 1872 178F A6FD 75F9 EB29

El 20/01/16 a las 22:21, Tim Griffin escribió:
> <http://api.rubyonrails.org/classes/ActiveRecord/Associations/Collecti
onProxy.html>.
> Tim
>
>
>
> -- You received this message because you are subscribed to the
> Google Groups "Hobo Users" group. To unsubscribe from this group
> and stop receiving emails from it, send an email to
> hobousers+...@googlegroups.com
> <mailto:hobousers+...@googlegroups.com>. To post to this
> group, send email to hobo...@googlegroups.com
> <mailto:hobo...@googlegroups.com>. Visit this group at
> https://groups.google.com/group/hobousers. For more options, visit
> https://groups.google.com/d/optout.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAlaf/LsACgkQF4+m/XX56ykDVwCcCcwcVKb7LFrSRoUD6hAJzfOi
6uUAn0VLR1/dW2kkZkDcD2wr5x8BsvRi
=DGXf
-----END PGP SIGNATURE-----
Reply all
Reply to author
Forward
0 new messages