Forum: Ruby on Rails in_place_editor_field problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0a012946a32e22f4c3a5ab6866e98e45?d=identicon&s=25 Dave Smith (smitty1276)
on 2007-07-18 22:32
I have a bit of a problem...

I am rendering a table of objects using a partial with a collection of
those objects.  Inside of the partial, I'm trying to use an
in_place_editor_field tag using the current object form the collection.
Rails doesn't seem to like this.

Does in_place_editor_field require a member variable that is set in the
controller?  Since I'm using a variable named after the partial (since
it is in a collection passed to the partial), is there anyway to get
those table rows to include in_place_editors without re-inventing the
wheel and writing my own code?
4375b4aca04b8d72482fd409fb6d0b47?d=identicon&s=25 Roderick van Domburg (roderickvd)
on 2007-07-18 22:55
Dave Smith wrote:
> Does in_place_editor_field require a member variable that is set in the
> controller?  Since I'm using a variable named after the partial (since
> it is in a collection passed to the partial), is there anyway to get
> those table rows to include in_place_editors without re-inventing the
> wheel and writing my own code?

You can just do a <% @member = my_thing %> in the partial.

--
Roderick van Domburg
http://www.nedforce.nl
C4bfcc81ac9281cb905f38e97e4d4e0b?d=identicon&s=25 Shandy Nantz (snantz)
on 2007-07-18 23:15
Dave Smith wrote:
> I have a bit of a problem...
>
> I am rendering a table of objects using a partial with a collection of
> those objects.  Inside of the partial, I'm trying to use an
> in_place_editor_field tag using the current object form the collection.
> Rails doesn't seem to like this.
>
> Does in_place_editor_field require a member variable that is set in the
> controller?  Since I'm using a variable named after the partial (since
> it is in a collection passed to the partial), is there anyway to get
> those table rows to include in_place_editors without re-inventing the
> wheel and writing my own code?

When I did my in_place_editor_field I had to put something like:

in_place_edit_for :user, :first

in the controller. Not sure why this code is required, I would be
interested to know why myself. I had help when doing my
in_place_edit_field. I imagine it's something like a pre-processing
directive.

~S
5e75f4b81923cd04a5c8fffa290be92e?d=identicon&s=25 Carl Johnson (carlivar)
on 2007-07-19 00:01
> When I did my in_place_editor_field I had to put something like:
>
> in_place_edit_for :user, :first
>
> in the controller. Not sure why this code is required

This creates the controller method that the in_place_editor_field
javascript calls.
This topic is locked and can not be replied to.