chell
chell

Reputation: 7866

Trouble with locals and partials with Rails

I have the following in my js.erb file:

$('#menu').after($("<%=escape_javascript(render 'boards/customize', :board => @board, :templates => @templates, :types => @types)%>") 

So I try to pass some locals to my partial

In my _customize.html.erb

<div id="customize">
          <ul id="categories">
            <% @types.each do |type|%>
            <li><%=link_to type.name, change_type_board_path(board, :type_id => type.id), :remote =>  true %></li>
            <% end %>
        </ul>
        <div id='carousel'>
            <%=render 'boards/carousel', :templates => templates %>
        </div>
    </div> 

I get the following error:

undefined local variable or methodboard' for #<#:0x00000103893e48`>

How are you supposed to pass in these variables to partials in Rails?

Upvotes: 1

Views: 133

Answers (1)

Tilo
Tilo

Reputation: 33732

In Rails 3:

render :partial => 'boards/customize', 
       :locals => { :board => @board , :templates => @templates, :types => @types }

Upvotes: 1

Related Questions