Passing an instance variable through RJS?
- by Elliot
Hey guys here is my code (roughly):
books.html.erb
<% @books.each do |book| %>
<% @bookid = book.id %>
<div id="enter_stuff">
<%= render "input", :bookid => @bookid %>
</div>
<%end%>
_input.html.erb
<% @book = Book.find_by_id(@bookid) %>
<strong>your book is: <%=h @book.name %></strong>
create.rjs
page.replace_html :enter_stuff, :partial => 'input', :object => @bookid
The problem here is that only create.js doesn't seem to work (though, if instead of passing the partial I passed "..." it does work, so I know its that there are instance variables in the partial that aren't being reset. Any ideas?)
So the final question, is how do I pass an instance variable to a partial through the create.rjs file?
p.s. I know I will have duplicate div IDs, I'm not worrying about that for now though.
Best,
Elliot