in_place_editor and lists

Hi All,

I’m trying to use the in_place_editor with a list and ended up having to do this:

<% for task in @tasks %>

  • <% @task = task %> <%= in_place_editor_field :task, :name %>

    Is there a way not to have to assign an instance variable for each task in @tasks just to use it with the in_place_editor_field?

    Thanks, Abdullah

  • Abdullah Jibaly wrote:

    I'm trying to use the in_place_editor with a list and ended up having to do this:

    <% for task in @tasks %>   <li>     <% @task = task %>     <%= in_place_editor_field :task, :name %> ...

    Is there a way not to have to assign an instance variable for each task in @tasks just to use it with the in_place_editor_field?

    for @task in @tasks

    Hi Mark, That gives me this error:

    NameError in

    Tasks#index Showing app/views/tasks/list.rhtml where line #9 raised:

    undefined local variable or method `task' for #<#<Class:0xb7844628>:0xb7844600>
    

    Thanks, Abdullah

    Abdullah Jibaly wrote:

    That gives me this error:

      NameError in Tasks#index

    Showing /app/views/tasks/list.rhtml/ where line *#9* raised:

    >undefined local variable or method `task' for #<#<Class:0xb7844628>:0xb7844600>|

    Abdullah, did you delete the <% @task = task %> line, and just have:

    <% for @task in @tasks %> <li> <%= in_place_editor_field :task, :name %> <% end %>

    ?

    Yeah, I did… I wonder why you can’t assign instance variables like that it the for loop.