In_place_edit_field help

Hello, i got this:

site_controller
Menu.content_columns.each do |column|
in_place_edit_for :menu, column.name
end

:menu, is a model with the sections names and contents

In my view i have:
<%= in_place_editor_field “dataCenter”,
‘content’,{},{:rows=>8,:cols=>5}%>

and it says:

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

Extracted source (around line #1):
1: <%= in_place_editor_field “dataCenter”,
‘content’,{},{:rows=>8,:cols=>5}%>

IF I PUT
<%= in_place_editor “dataCenter”, ‘content’,{}%>, it does the work but
without the size i want, i mean it just present all the data in a field.

Any helps will be good,
Regards,

I believe you need to swap your options around and send the size through
the tag_options not editor_options like this:

<%= in_place_editor_field
“dataCenter”,‘content’,{:rows=>8,:cols=>5},{}%>

Edgar G. wrote:

<%= in_place_editor_field “dataCenter”,

IF I PUT
<%= in_place_editor “dataCenter”, ‘content’,{}%>, it does the work but
without the size i want, i mean it just present all the data in a field.

Any helps will be good,
Regards,


Sincerely,

William P.

actually, you can leave the last ar out completely (still on first cup
of coffee :slight_smile:

<%= in_place_editor_field “dataCenter”,‘content’, :rows=>8, :cols=>5 %>

William P. wrote:

<%= in_place_editor “dataCenter”, ‘content’,{}%>, it does the work but
without the size i want, i mean it just present all the data in a field.

Any helps will be good,
Regards,


Sincerely,

William P.

Hey!, thanks for your answers, but i still get this message: :frowning:

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

If you use this the in-place editor is looking for a variable called
@dataCenter. Did you come from Java? The ruby conventions is
data_center as a variable name. I’m guessing you are inside of a
partial that you are passing a collection? So your partial is
creating a variable called dataCenter. So just add a line above your
current line. Like this:

<% @dataCenter = dataCenter %>
<%= in_place_editor_field “dataCenter”,‘content’, :rows=>8, :cols=>5 %>

You may also want to change dataCenter into a symbol, like :dataCenter.

hey! thanks Amos, it was because i was in a parcial,
but could you explain me why i had to do the <% @dataCenter = dataCenter
%>??

When you use a collections partial it takes each item in the
collection and passes it to a variable with the same name as your
partial. ie;

I have a variable called @items that is an array of Item(s)

<%= render :partial => ‘item’, :collection => @items %>

Inside the partial now there is an variable called item.
Now I have the following in my partial:

<%= in_place_editor :item, “name” %>

The in-place editor isn’t looking for item, but is looking for @item.
I believe that this should be changed, but that is the way it was
made. So above that line I have to create @item so that in-place
editor can use it.

If I was writing a function the collections partial would have a
signature like this:

render( partial, collection )

The variable partial is what is used as your variable name in the
partial you created.

Now the in-place-editor is looking for @partial. I hope that doesn’t
confuse you.

-Amos

On 8/22/07, Edgar G. [email protected] wrote:

hey! thanks Amos, it was because i was in a parcial,
but could you explain me why i had to do the <% @dataCenter = dataCenter
%>??

Posted via http://www.ruby-forum.com/.


Amos K.
A. King Software Development and Consulting, L.C.
http://dirtyInformation.com

Looking for something to do? Visit http://ImThere.com