Unpopulated in_place_editor_field not working

Hi:

I have a show page with an in place editor field for description. It
works great when description is populated. description can be nil, so I
notice that when I show a record with no description, the in place
editor either doesn’t work or has no place to click to edit. This is
still something i’d like to have work. Is there something additional I
have to do for when description isn’t populated?

from the view:

Description:
<%= in_place_editor_field :goal, :description %>

Thanks so much in advance!

Mike

Mike D. wrote:

Description:
<%= in_place_editor_field :goal, :description %>

Thanks so much in advance!

Mike


Posted via http://www.ruby-forum.com/.

use the :external_control option on the in_place_editor_field

its the easiest way.

I read in Rails Recipes, that for in-place-editing to work, you need to
have some value populated. Something like ‘click to edit’…

nolifetillpleather wrote:

Mike D. wrote:

Description:
<%= in_place_editor_field :goal, :description %>

Thanks so much in advance!

Mike


Posted via http://www.ruby-forum.com/.

use the :external_control option on the in_place_editor_field

its the easiest way.

Thanks for this option. I was unable to find it in the api, so I tried:
Description:
<%= in_place_editor_field :goal, :description, :external_control %>

But that didn’t work. Then I fooled around a bit until I got to:

Description:
<%= in_place_editor_field :goal, :description,
:in_place_editor_options => :external_control %>

And that compiled but still didn’t work. Any further sugestions besides
setting the default value in the DB to “Add a description here” as the
other poster suggests?

Thanks again!

Mike

Any further sugestions besides setting the default value in the DB to
“Add a description here” as the other poster suggests?
I sure wish someone could answer this question. I have been poking
around
and don’t see anything that explains the syntax of the
in_place_editor_options well enough that I can make this work. One thing
that I wasted a bunch of time on was the :click_to_edit_text - that
isn’t
what Mike and I want. Instead it is supposed to change the tooltip text
when
you mouse over the text to edit.

Is there a way for me to create a non-database backed attribute for the
fake
text? and then still have the real attribute edited? It doesn’t look
like
that is easy to do the way the In Place Editor API is set up.


Cynthia K.
[email protected]

I ran into this problem as well with in_place_editor. The :empty_text
parameter hack is good. What I wound up doing is using an
:external_control which is small-font “edit” text right next to whatever
someone might want to edit. If the data is nil the “edit” link is still
there. I find this looks better anyway, since short-length values are
not that easy to click on.

Here’s my code:

<% if logged_in? && admin? %>
<%=edit_text(@style,‘style_num’)%> 
<% end %>
<%= in_place_editor_field(‘style’,‘style_num’,{},{:external_control =>
edit_id(@style,‘style_num’), :size => 10})%>

and as helpers:

def edit_id(object,field)
“edit_#{object.class.to_s.downcase}#{object.id}#{field}”
end

def edit_text(object,field)
“<span class="edit" id="#{edit_id(object,field)}">edit”
end

Also, a warning: in_place_editor is broken for non-string values! If you
try to change an integer type to nil (remove it, basically) you get a
nasty error. I submitted a very easy patch for this:

http://dev.rubyonrails.org/ticket/7067

No action on it yet though. :frowning:

More searching turned up a post to this list referencing:
http://www.akuaku.org/archives/2006/08/in_place_editor_1.shtml

I dropped it in, restarted my server, and then started using it. For
other newbies, that involved changing the controller line to add the
:empty_text parameter:
in_place_edit_for :page, :comments, :empty_text => ‘(add comment)’
And changing my invocation of in_place_editor_field to include the
in_place_editor_options hash:
<%= in_place_editor_field :page, :comments, {}, {
:nil_content_replacement => ‘(add comment)’ } %>


Cynthia K.
[email protected]

Its working for me with Integers and Strings, but I get an error on
Float fields. It says
Undefined method `size’ for 0.03:Float

It does change the value in the database though…

On Jan 22, 11:04 pm, Carl J. [email protected]

nolifetillpleather wrote:

Its working for me with Integers and Strings

What happens if you change an integer type to nothing? For example if it
is currently 5000, blank it out.

ah, you are right. template missing error. value is updated in the
database.

On Jan 23, 4:50 pm, Carl J. [email protected]