views:

47

answers:

1

So I put in in-place editing for one of my models.

One of the attributes is PRICE. I used the to_currency method to format the value before it is displayed.

The problem I'm having is that with the in-place editor, I just can't figure out how to set a custom display value.

I'm trying to get the price to display as $20.00 until it is clicked, but the in place editor displays 20.0..

implementation is fairly standard:

controller code

in_place_edit_for :product, :price

view code

<%= in_place_editor_field :book_post, :course %>

I looked at the documentation, and there appears to be an option

:load_text_url: URL where initial value of editor (content) is retrieved.

but I can't figure out how to use it...

A: 

I myself use code as described here.

Looking at the code from the plugin, it is way better, although you loose a bit of control.

How the :load_text_url would work, i guess, is that you would provide a method inside the controller

def show_value
  @record = Record.find(:params[:id])
  render :text => "${@record.your_value.to_s}"
end

and inside your view you write

<%= in_place_editor_field :book_post, :course, :load_text_url => { :action => :show_value, :id => @record.id } %>

something along those lines. Not sure though. But i hope it gets you started.

nathanvda