Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have figured out a way to successfully render the like/unlike form for a member's individual post. While this is uncanny, space consuming and above all: lacks trend; it <em>does</em> work. </p> <p>Instead of rendering <code>like_form.html.erb</code>, I added the code directly to <code>share_item.html.erb</code> and told the form not to look for <code>@thought</code> but rather to look for <code>share_item</code> (which is the individual item within the collection of <code>@share_items</code> nested inside <code>class Thought</code>)</p> <p><code>thoughts/unlike.html.erb</code> now looks like:</p> <pre><code>&lt;%= form_for(registered_member.opinions.find_by_like_id(share_item), html: { method: :delete }, remote: true) do |f| %&gt; &lt;%= f.submit "Unlike", class: "btn btn-small btn-default" %&gt; &lt;% end %&gt; </code></pre> <p>and <code>thoughts/like.html.erb</code></p> <pre><code>&lt;%= form_for(registered_member.opinions.build(like_id: share_item.id), remote: true) do |f| %&gt; &lt;div&gt;&lt;%= f.hidden_field :like_id %&gt;&lt;/div&gt; &lt;%= f.submit "Like", class: "btn btn-small btn-primary" %&gt; &lt;% end %&gt; </code></pre> <p>and I could omit <code>&lt;%= @thought.id %&gt;</code> from the js so it looks like <code>("#like_form")</code></p> <p>As I said, this junks up my partial having to add the code inside of it rather than rendering the form partial, but if I do the latter, I get the error that "share_item is an unknown or undefined local variable" While I have accomplished my initial goal getting the form to actually work, I am still seeking suggestions as to how I could render the form rather than adding it directly to my partial, without getting that error message.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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