0

I need to better manipulate a strong for a collection_select. I only see how to call a function on the object, but I need to do some more manipulation that the object won't know about. Is there a way to do this?

Currently:

lif.collection_select(:tier_id, @lif_plan.tiers, :id, :tiername) 

I tried this and it didn't work (thinking it would pass the tier object in)

lif.collection_select(:tier_id, @lif_plan.tiers, :id, {|tier| "#{tier.tiername} - #{@member.tierrate(year_of_rate)} "} ) 

My challenge is that the tier will not know what it should be doing without additional information so I can't just make a function in there to return. Any help or suggestions would be appreciated!

MechDog
  • 508
  • 7
  • 18

1 Answers1

1

You were almost there, remember that collection_select is expecting a Proc/Method there. So it will try to send a :call message to it.

Change it to the following and try again:

lif.collection_select(:tier_id, @lif_plan.tiers, :id, Proc.new {|tier| "#{tier.tiername} - #{@member.tierrate(year_of_rate)} "} )
SomeDudeSomewhere
  • 3,928
  • 1
  • 23
  • 27
  • Thanks for the help! I ended up switching to the select command for it but will use this going forward! lif.select(:tier_id, @lif_plan_tiers.map {|tier| ["#{tier.tiername} - #{@member.tierrate(year_of_rate)} ", tier.id]}) – MechDog Oct 13 '14 at 15:31