Forum: Ruby on Rails In Place Editor options

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
shanev (Guest)
on 2005-11-16 08:40
(Received via mailing list)
I want my in place editor to be a textarea instead of a textfield.
I am doing the following:

in_place_edit_for :event, :notes

<%= in_place_editor_field :event, :notes, :rows => 5 %>

The method signature for in_place_editor_field is (object, method,
tag_options = {}, in_place_editor_options = {}). I'm a Ruby newbie but I
understand that the last two hashes will be combined into one, so I
have to explicity have an empty {} in there. According to the source,
in_place_editor_field calls in_place_editor passing in the options hash.
in_place_editor should pass along the 'rows' argument to the
Ajax.InPlaceEditor javascript function. It looks like it should work
by the source, but I still get only 1 row. I tried some of the other
options, such as :okay_text and :cancel_text which don't work either. Am
missing something?

james.adam (Guest)
on 2005-11-16 13:05
(Received via mailing list)
On 11/16/05, Shane V. <removed_email_address@domain.invalid> wrote:
> I'm a Ruby newbie but I
> understand that the last two hashes will be combined into one, so I don't
> have to explicity have an empty {} in there.

This isn't true. Arguments which look like key => value pairs will be
collected into a single Hash if now bracketing is given, but this
single hash will be used for the tag_options parameter. For example:

  in_place_editor_field(arg1, arg2, :key1 => val1, :key2 => val2, :key3
=> val3)

is the same as

  in_place_editor_field(arg1, arg2, {:key1 => val1, :key2 => val2,
:key3 => val3})

... so the in_place_editor_options will be given the default value of
an empty hash. If you want to pass anything for the
in_place_editor_options parameter, you need to be explicit with your
Hash brackets, i.e.

  in_place_editor_field(arg1, arg2, {:key1 => val1, :key2 => val2},
{:in_place_option => val3})

So, in your example

  <%= in_place_editor_field :event, :notes, :rows => 5 %>

The paramter {:rows => 5 } is actually a part of the tag_options, when
as far as I can tell, it should be in the in_place_editor_options. You
want something like this (formatted weirdly here for comments):

  <%= in_place_editor_field(:event, :notes,
           # tag_options
                                                  {:rows => 5})
  # in_place_editor_options

- james
shanev (Guest)
on 2005-11-16 16:53
(Received via mailing list)

Thanks! That worked. I actually did try putting in the brackets before
I figured, as you did, that all key => value pairs would be collected
into a
the tag_options hash. However I tried it with the "cancel_text"
which still doesn't seem to work. So thats why I assumed it wouldn't
with "rows."

I also found a minor bug in the 0.14.3 version of the Rdocs. The
argument should actually be "save_text" since that is what the code is
looking for. Didn't check to see if this was logged yet.

Appreciate the help.

This topic is locked and can not be replied to.