Help me get in_place_edit working

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.

On 12/6/06, Nathan [email protected] 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

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

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.

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

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.