Note that there are some explanatory texts on larger screens.

plurals
  1. POmy final step in the rails app, how to make comments appear in a popup?
    primarykey
    data
    text
    <p>This is the last remaining item to complete my first rails app and need some help. On each user profile (localhost:3000/users/username), there's a listing of posts that the user has made. Associated with each post are comments. So post_id: 3 could have comments. </p> <p>I have it working already in view form but I need the comments to appear in a popup instead when the "Comments" link under each post is clicked. I have already applied facebox which is a jQuery-based lightbox that displays popups. </p> <p>I just need to move what's currently shown in show.html.erb into a popup. </p> <p>There's the _comment_form.html.erb which renders into _post.html.erb</p> <pre><code> &lt;%= link_to #, :rel =&gt; "facebox-#{post.id}" do %&gt; +&lt;%= post.comments.count.to_s %&gt; &lt;% end %&gt; &lt;div class ="ItemComments"&gt;&lt;% if post.comments.exists? %&gt; &lt;% post.comments.each do |comment| %&gt; &lt;%= image_tag("http://www.gravatar.com/avatar.php?gravatar_id=#{Digest::MD5::hexdigest(comment.user.email)}" %&gt; &lt;span class="users"&gt;&lt;%= link_to comment.user.name, comment.user %&gt;&lt;/span&gt; &lt;span class="timestamp"&gt;&lt;%= time_ago_in_words(comment.created_at) %&gt; ago&lt;/span&gt; &lt;span class="content2"&gt;&lt;%= comment.comment_content %&gt;&lt;/span&gt; &lt;% end %&gt; &lt;% end %&gt;&lt;/div&gt; </code></pre> <p>The above renders into _post.html.erb using:</p> <pre><code>&lt;%= render 'shared/comment_form', post: post if signed_in?%&gt; </code></pre> <p>Then it renders into show.html.erb</p> <p>I'm trying to use this line, but what do I link it to?</p> <pre><code> &lt;%= link_to #, :rel =&gt; "facebox-#{post.id}" do %&gt; +&lt;%= post.comments.count.to_s %&gt; &lt;% end %&gt; </code></pre> <p>This is shared/_comment.html.erb</p> <pre><code>&lt;% if post.comments.exists? %&gt; &lt;% post.comments.each do |comment| %&gt; &lt;%= image_tag("http://www.gravatar.com/avatar.php?gravatar") %&gt; &lt;%= link_to comment.user.name, comment.user %&gt; &lt;span class="timestamp"&gt;&lt;%= time_ago_in_words(comment.created_at) %&gt; ago&lt;/span&gt; &lt;span class="content2"&gt;&lt;%= comment.comment_content %&gt;&lt;/span&gt; &lt;% end %&gt; &lt;% end %&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload