nathanvda / on_the_spot

A rails3 unobtrusive in-place-editing plugin, using jQuery/jEditable.
MIT License
132 stars 37 forks source link

number_to_currency method support? #16

Closed klebershimabuku closed 13 years ago

klebershimabuku commented 13 years ago

Hi,

I'm trying to use the method number_to_currency but it looks like have no support for it until now.

Thats the way I'm doing:

<% @part_types.each do |part_type| %>

<%= on_the_spot_edit part_type, :title %> <%= on_the_spot_edit part_type, number_to_currency(:quotation) %>

<% end %>

The error I get is:

Undefined method "to_f"

Just doing:

number_to_currency(part_type.quotation)

works fine.

nathanvda commented 13 years ago

Hi there, it would help if you would give file-line-nr where the error happened.

But anyway, when using on_the_spot_edit, the second parameter always needs to be the fieldname. If you want to change what is shown, you can do write something like:

<%= on_the_spot_edit part_type, :quotation, :display_text => number_to_currency(:quotation) %>

But I am not sure if converting the currency back to number will work, when saving it to the controller. You might need to use your own method to convert the currency back to number correctly.

klebershimabuku commented 13 years ago

You right, I will need to create a method to convert the saved number (decimal) to display correctly.

I don't know if it's the right way for doing this, but I just created a helper method and did the convert to display as string and it worked.

Thank you for your support.

nathanvda commented 13 years ago

Ok. Great you found a solution.