Forum: Ruby on Rails How to use in_place_editor_field ?

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.
Nuno (Guest)
on 2006-04-04 11:58
Hello, I really don't understand how to use in_place_editor_field

In my controller :
class Admin::CategoriesController < Admin::BaseController
  in_place_edit_for :category, :title

  def list
    @categories = Category.find_all
  end

end

In the view list.rhtml
<% @categories.each do |c| %>
  <td><%= in_place_editor_field :c, c.title %></td>
  # snip
<% end %>

I get error
Called id for nil, which would mistakenly be 4 -- if you really wanted
the id of nil, use object_id

I've tried
in_place_editor_field :c, 'title'
in_place_editor_field :c, :title
in_place_editor_field :c, 'c.title'

nothing work, what is the right syntax ?

Thank you
Mats L. (Guest)
on 2006-04-04 12:35
(Received via mailing list)
_______________________________________________
Rails mailing list
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails
Andrew D. Goodfellow (Guest)
on 2006-04-04 20:34
(Received via mailing list)
I have the exact same result when I try.

Called id for nil, which would mistakenly be 4 -- if you really wanted
the id of nil, use object_id

Is there some documentation on this somewhere? We must obviously be
using it wrong...

-Andy
Nuno (Guest)
on 2006-04-04 21:33
Andrew D. Goodfellow wrote:
> I have the exact same result when I try.
>
> Called id for nil, which would mistakenly be 4 -- if you really wanted
> the id of nil, use object_id
>
> Is there some documentation on this somewhere? We must obviously be
> using it wrong...
>
> -Andy

Okay, I found it but it's really really weird

<% @categories.each do |c| %>
  <%= @category = c; in_place_editor_field :category, :title %>
  # snip
<% end %>

Or may we might write ?
<% @categories.each do |@c| %>
  <%= in_place_editor_field :c, :title %>
  # snip
<% end %>

Didn't tried the last one

I really don't understand why a local object instance doesn't do the job
This topic is locked and can not be replied to.