I think we’ll stick with `posts.group_by(&:id).transform_values { |v| v.title.uppercase }` — and it’s not because we don’t `value_fun`! 😄
> Den 5. dec. 2017 kl. 01.48 skrev David Carlin <david.car...@cultureamp.com>: > > Elixir has a great feature in its Enumerable,group_by/3 function where you > can pass 2 functions to it. The first being what to group by (called a > key_fun). The second being a function that returns the val (called the > value_fun). See: https://hexdocs.pm/elixir/Enum.html#group_by/3 > > By default the value_fun is a function that does nothing ie. fn x -> x end > (making its default behaviour the same as Ruby/Rails group_by method) > > I would like this functionality in Rails. What do you think, dear community? > > (Apologies if this has been brought up before. I did a quick search but found > nothing) > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscr...@googlegroups.com > <mailto:rubyonrails-core+unsubscr...@googlegroups.com>. > To post to this group, send email to rubyonrails-core@googlegroups.com > <mailto:rubyonrails-core@googlegroups.com>. > Visit this group at https://groups.google.com/group/rubyonrails-core > <https://groups.google.com/group/rubyonrails-core>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- Kasper -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.