>
> > That's obviously not the problem then, strange. Is this to go down as
> > one of the great unsolved mysteries of the universe?
>
> > Colin
>
> maybe not, I begin to suspect that I have messed up my rails
> installation.
solved it, I think. It was unbelievably simple
following code in view works:
<%= render :partial => 'forum_posts/recursive_comments', :locals =>
{:post_id => @forum_post.id} %>
in partial I had to do following:
<% def show_comments(post_id, kind=:children, fcomment=nil)
if kind==:parents
comments=ForumComment.find(:all,:conditions => [ "forum_post_id
= ? and parent_comment_id is null", params[:id]] )
colour='green'
elsif kind==:children
comments=ForumComment.find(:all, :conditions =>
["parent_comment_id = ? and forum_post_id = ?",
fcomment,params[:id]] )
colour='red'
else
raise "wrong kind: shoul be either :parents or children but not
#{kind}"
end
%>
<% comments.each do |comment| %>
<div style="border: solid <%= colour%> 1px;margin:0.25em;padding-
left:1em ;">
<%#= h comment.inspect %>
<h4><%= h comment.title%></h4>
<p><%= h comment.text%></p>
<% usr=User.find(comment.user_id)%>
<p class="whowhen"><%= h usr.login+' '+comment.created_at.to_s%>
<%= link_to 'Reply',{:controller
=> :forum_comments, :action=> :new,:parent_id=> comment.id,:forum =>
post_id } %>
</p>
<% show_comments(post_id,:children,comment) unless comment==nil
%>
</div>
<% end %>
<% end %>
<
%######################################################################
%>
<% show_comments(post_id,:parents) %>
so after because the link_to was within a method I had to pass the
partials local as a parameter.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment