[Rails] How do you make in_place_edit fields appear when empty?

Nathan Leach
2006-05-11T20:19:39Z

Well, since I got a clamoring response to this question, I thought I would post
what I did back to the list.  Maybe my hair-brained answer will evoke some
better solutions ;-)

The jist of it is that I query the contents of each field, and when empty put in
a default value (my choice was a "?").  That shows the user that a
value is needed and alows in_place_edit to show the field.

In the order view, with shipping point as the example field...

<% if @order.shippingpoint.empty? %>
    <%= @order.shippingpoint = "?" %>
<% end %>
<%= in_place_editor_field :order, :shippingpoint %>

I would really like to see something that doesn''t involve custom code
for each field or putting garbage data in the field as a default value.  I am no
Javascript expert (obviously).  Maybe there is a nice solution using Javascript
helpers, etc.?

Nathan

-----Original Message-----
From: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org]On Behalf Of Nathan Leach
Sent: Thursday, May 11, 2006 10:12 AM
To: rails@lists.rubyonrails.org
Subject: [Rails] How do you make in_place_edit fields appear when empty?



Here''s a simple one...

When using in_place_edit fields, they don''t appear unless they already
have a value.  How can I get similar functionality when they are empty?

Thanks,
Nathan

-------------- next part --------------
An HTML attachment was scrubbed...