Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my hidden_field being ignored? Not passing parameter
    primarykey
    data
    text
    <p>I am trying to toggle a subscribe btn back and forth using Ajax But the hidden field isnt doing anything at all. I've tried setting a , value: 4 or wrapping the form in escape_js but still doesn't even show up.</p> <p>relationship/destroy.js.erb: </p> <pre><code>$("#unfollow_&lt;%=@user.id%&gt;").replaceWith('&lt;div id="follow_&lt;%=@user.id%&gt;"&gt;&lt;%= form_for(current_user.relationships.build(followed_id: @user.id), remote: true) do |f| f.hidden_field :followed_id f.submit "Subscribe" end %&gt;&lt;/div&gt;') </code></pre> <p>logs:</p> <pre><code>Started POST "/relationships" for 127.0.0.1 at 2013-06-21 05:38:46 -0400 Processing by RelationshipsController#create as JS Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"Jx9SG25KLJH5UfstrOw3RudtgqJtKwidvT4xGt+bqas=", "commit"=&gt;"Subscribe ∞"} User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."remember_token" = '1gPcW8-7ey4aSGV-g1O_lw' LIMIT 1 Completed 500 Internal Server Error in 2ms NoMethodError (undefined method `[]' for nil:NilClass): app/controllers/relationships_controller.rb:6:in `create' </code></pre> <p>The POST is missing this parameter (the input is missing in the html as well): </p> <pre><code>"relationship"=&gt;{"followed_id"=&gt;"46"} &lt;input id="relationship_followed_id" name="relationship[followed_id]" type="hidden" value="92" /&gt; </code></pre> <p>When I try:</p> <pre><code>f.hidden_field followed_id: @user.id </code></pre> <p>I get undefined method `{:followed_id=>2}' for # <p>RelationshipController for kicks:</p> <pre><code>def create @user = User.find(params[:relationship][:followed_id]) current_user.follow!(@user) respond_to do |format| format.html { redirect_to :back } format.js end end def destroy @user = Relationship.find(params[:id]).followed current_user.unfollow!(@user) respond_to do |format| format.html { redirect_to :back } format.js end end </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.
    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