Hi,
I use Rails 2.5 and have following problem. I’m trying to pass local
variable to a partial view, as explained in
section 3.4.4
I have following code in /app/views/forum_posts/show.html.erb
<%= render :partial => ‘forum_posts/recursive_comments’, :locals =>
{ :fp => @forum_post } %>
and following code in /app/views/forum_posts/
_recursive_comments.html.erb
<% myvar=:fp %>
<%= h myvar.inspect %>
<%= h myvar.class %>
<%= link_to ‘Reply’,{:controller
=> :forum_comments, :action=> :new,:parent_id=> comment.id,:forum =>
myvar} %>
When I click on the link I get:
http://example.com/forum_comments/new?forum=fp&parent_id=2
instead of:
http://example.com/forum_comments/new?forum=1&parent_id=2
For some strange reason symbol :fp is being passed to the partial.
Please help me and explain where I misunderstood the manual. I want to
pass value of @forum_post.id to the partial. If I don’t get
satisfactory response I intend to move everything into the view, which
means code duplication , because I planned to do similar with blog
coments.
I know that I could use some plugin, but I want to do it learn more
about Rails, so kindly please respond regarding passing information to
partials, or suggest other solution that doesn’t require a plugin.
Jack