I have a Rails app deployed on Heroku. It’s the Twitter app given in a lot of samples. I was trying to learn how to git a Rails app deployed on Heroku. Anyway, when clicking on the follow button, nothing happens. I used heroku logs and found this to be the issue:
NoMethodError (undefined method `[]' for nil:NilClass):
app/controllers/user_relationships_controller.rb:6:in `create'
The parameters passed are this:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"NIiiOgQ4iowSxezGmvLk3oV/vul+4ysWoFrgh/1eOAY=", "user_id"=>{"follower_id"=>"1"}, "commit"=>"follow"}
Which corresponds to this line:
@user = User.find(params[:user_id][:follower_id])
Could someone please point me in the right direction? Thanks!
As requested:
<%= form_for current_user.user.build(:follower_id => @user.id),
:remote => true do |f| %>
<div><%= f.hidden_field :follower_id %></div>
<div class="actions"><%= f.submit "follow" %></div>
<% end %>
$('#follow_form').replaceWith("<%= escape_javascript render(:file =>'users/_follow_form') %>");
$('#followers').replaceWith('<div id="followers"><h1><%= "Followers: #{@user.followers.count}" %></h1></div>');
I’m terribly sorry I bothered you with this. For whatever reason, I had two controllers named very similarly. It was using the wrong one and I didn’t realize it. I switched the code and now it works. Thanks for the input!