Open cipacda opened 10 years ago
@cipacda could you provide code, that not working?
best_in_place_if editable, payment, :payment_method, :as => :select, :collection => PaymentMethod.all. each_with_object({}){|o, h| h[o.id.to_s] = o.name }
:payment_method is an object which has an id and a name. I would like to be able to display the name of the current payment_method selected.
Currently I added the following hack: best_in_place_if editable, payment, :payment_method_id, :as => :select, :collection => PaymentMethod.all. each_with_object({}){|o, h| h[o.id.to_s] = o.name }
and updated the controller's update action to deal with :payment_method_id, which is not ideal.
@cipacda what about :display_as option?
display_as/with is bad, don't use it.
@cipacda @seuros :value?
:value, is what he needs i think. for info display_as/with is not thread-safe and won't work in a multiserver setup. We probably need to remove it and use a frontend script to format the reply.
:value only updates the 'bip-content-original' and not the 'bip-value', the one that looks to be the one used to display the value.
See https://github.com/bernat/best_in_place/blob/master/lib/best_in_place/helper.rb lines 54 and 59.
Is anyone still looking at this? Or can anyone give me a reason for why this cannot be done?
@cipacda maybe @seuros
@cipacda is it actual for latest master? I made some improvements for collection parameter
@stereodenis On the latest master, the issue I am having is that when using best_in_place_if, if the value should not be editable, I get the id displayed, and not the name. This is what I am passing to the collection parameter:
:collection => entries.each_with_object({}){|o, h| h[o.id.to_s] = o.name }
@cipacda could you show me the output of this entries.each_with_object({}){|o, h| h[o.id.to_s] = o.name }
and the data-bip-collection output
or
make a test app for this issue
This would help in cases where I have a select for another type, which is a child of the current object.