# Help me get in\_place\_edit working

**URL:** <https://www.ruby-forum.com/t/help-me-get-in-place-edit-working/78489>\
**Category:** Rails\
**Created:** [December 6, 2006, 6:38am UTC](https://www.ruby-forum.com/t/help-me-get-in-place-edit-working/78489 "2006-12-06T06:38:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c5a1d2/32.png) [@nathan](https://www.ruby-forum.com/u/nathan)\
**Post date:** [December 6, 2006, 6:38am UTC](https://www.ruby-forum.com/t/help-me-get-in-place-edit-working/78489/1 "2006-12-06T06:38:04Z")

</div>

I am trying to use Ruby on Rails’ built in in\_place\_editor\_field helper.  
Which in theory makes a paragraph of text on my screen editable right  
where it sits.

I’ve followed all of the documentation I could find very carefully, but  
no matter what I do it still will not work even in the simplest example.  
Which from my understanding, this should make a paragraph of text that  
reads ‘description’ which I can click, edit, and save.

Controller (Right under the controller declaration):  
in\_place\_edit\_for :product, :description

View:  
\<%= in\_place\_editor\_field :product, ‘description’ %\>

In the View header:  
\<%= javascript\_include\_tag :defaults %\>

This throws the error when I launch it: _Called id for nil, which would  
mistakenly be 4 – if you really wanted the id of nil, use object\_id_  
around here: _\<%= in\_place\_editor\_field :product, ‘description’ %\>_ This  
is a real bummer because I want to do something a little bit more  
complex, I want to edit fields in a database but it goes without saying  
those examples I couldn’t make work either from the get go.

---

<div class="post-metadata">

**Author:** ![nathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c5a1d2/32.png) [@nathan](https://www.ruby-forum.com/u/nathan)\
**Post date:** [December 6, 2006, 7:08am UTC](https://www.ruby-forum.com/t/help-me-get-in-place-edit-working/78489/2 "2006-12-06T07:08:24Z")

</div>

On 12/6/06, Nathan [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Controller (Right under the controller declaration):  
> around here: _\<%= in\_place\_editor\_field :product, ‘description’ %\>_ This  
> is a real bummer because I want to do something a little bit more  
> complex, I want to edit fields in a database but it goes without saying  
> those examples I couldn’t make work either from the get go.

You need an instance variable “@product” at the time the view is  
rendered - do you have one?

I.e.:

def show  
@product=Product.find(params[:id])  
end

Same for new/create.

Cheers,  
Max

---

<div class="post-metadata">

**Author:** ![nathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c5a1d2/32.png) [@nathan](https://www.ruby-forum.com/u/nathan)\
**Post date:** [December 6, 2006, 10:53am UTC](https://www.ruby-forum.com/t/help-me-get-in-place-edit-working/78489/3 "2006-12-06T10:53:58Z")

</div>

Max M. wrote:

> You need an instance variable “@product” at the time the view is  
> rendered - do you have one?
> 
> I.e.:
> 
> def show  
> @product=Product.find(params[:id])  
> end
> 
> Same for new/create.
> 
> Cheers,  
> Max

That’s exactly what it was, man I’ve been trying to understand how this  
works for a whole week now. It wasn’t making any sense to me at all,  
this is a little bit better.

However now when I try to make a change to the paragraph stored in my  
database it throws a pop-up exception error.

Action Controller: Exception caught  
Uninitialized constant Product

---

<div class="post-metadata">

**Author:** ![nathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c5a1d2/32.png) [@nathan](https://www.ruby-forum.com/u/nathan)\
**Post date:** [December 6, 2006, 12:40pm UTC](https://www.ruby-forum.com/t/help-me-get-in-place-edit-working/78489/4 "2006-12-06T12:40:40Z")

</div>

I got this to work, by renaming everything from “Product” to the actual  
model name. Still I don’t fully understand the mechanics of how this  
works but at least it works now.

---

<div class="post-metadata">

**Author:** ![nathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c5a1d2/32.png) [@nathan](https://www.ruby-forum.com/u/nathan)\
**Post date:** [December 6, 2006, 11:47am UTC](https://www.ruby-forum.com/t/help-me-get-in-place-edit-working/78489/5 "2006-12-06T11:47:50Z")

</div>

Actually I get the same type of error using the examples on this page as  
well:

[http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor](http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor)

---

<div class="post-metadata">

**Author:** ![nathan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/c5a1d2/32.png) [@nathan](https://www.ruby-forum.com/u/nathan)\
**Post date:** [December 6, 2006, 1:09pm UTC](https://www.ruby-forum.com/t/help-me-get-in-place-edit-working/78489/6 "2006-12-06T13:09:35Z")

</div>

May-as-well keep this topic going though, how can I have an  
in\_place\_editor\_field use simple\_format when not in editing mode. This  
is so when you aren`t editing the text, HTML will display all necessary  
line breaks.
