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.
A5d8283732da86365736508fef6c1c67?d=identicon&s=25 Nuno (Guest)
on 2006-04-04 09: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
1aa112c30efa4109f938e7676c3808b6?d=identicon&s=25 Mats Lindblad (Guest)
on 2006-04-04 10:35
(Received via mailing list)
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
A3f2156480bc18e8232f99626cdcfe63?d=identicon&s=25 Andrew D. Goodfellow (Guest)
on 2006-04-04 18: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
A5d8283732da86365736508fef6c1c67?d=identicon&s=25 Nuno (Guest)
on 2006-04-04 19: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.