Trouble passing locals in Partial

760 views Asked by At

I have a partial called _avatar.html.erb I want to pass in an id as a local variable called entity_id which will be the id of an object.

<% form_tag({:controller => "avatar", :action => "upload", :id => entity_id},
     :multipart => true ) do %>
    <fieldset>
      <legend><%= title %></legend>
      <% if avatar.exists? %>
      <%= avatar_tag(avatar) %>
      [<%= link_to "delete", {:controller => "avatar",:action => "delete", 
           :id => entity_id},:confirm => "Are you sure" %>]
     ...

Here is the call for the parital:

<%= render :partial => 'avatar/avatar', :locals => {:avatar => @avatar, 
    :title => @title, :entity_id => @board.id } %>

When I try this I get the following errors:

undefined local variable or method `entity_id' for #<ActionView::Base:0x2736bb0>

When I take that out I also get an error telling me it can't find the local variable "title".

Can anyone help this seems to be the correct way to do this.

Thanks in advance

1

There are 1 answers

1
Jas On BEST ANSWER

Try using :id=>@entity_id (note the @ symbol preceding the name). Likewise, @title, instead of "title".