views:

18

answers:

1

Hello, I'm using rails 3 and am trying to use the in_place_editing plugin:

http://github.com/wanglian/in_place_editing

 # Controller
  class BlogController < ApplicationController
    in_place_edit_for :post, :title
  end

  # View
  <%= in_place_editor_field :post, 'title' %>

However I'm getting the error: id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id

I'm calling the plugin in my photo_album controller, which has a title attribute...

class PhotoAlbumsController < ApplicationController

  in_place_edit_for :photo_album, :title

The in the Index View, I'm doing the following:

<% @photoalbums.each do |photoalbum| %>
     <%= in_place_editor_field :photoalbum, 'title' %>
<% end %>

Does anyone understand this or have experience with this plugin?

Thanks

A: 

The error is because, its trying to update the title of a nil object. You should use this instead

<% @photoalbums.each do |photoalbum| %>
     <%= in_place_editor_field photoalbum, 'title' %>
<% end %>

if you see the code of the plugin the definition of the method is

def in_place_editor_field(object, method, tag_options = {}, in_place_editor_options = {})
Rishav Rastogi
strange that errord.
TheExit
Still: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
TheExit
<% @photoalbums.each do |photoalbum| %> <%= photoalbum.inspect%>: #<PhotoAlbum id: 3, title: "Bark", description: nil, user_id: 1,
TheExit
Can paste the whole error stack?
Rishav Rastogi