Clarification in the docs
Closed this issue · 2 comments
Hey, first off, THANKS! This gem is awesome
One Issue I am having (due to the fact I'm new to rails and Ruby, not an issue with your gem) is implementing it in a form.
Could you provide an example of how one would implement it from controller to view?
for example, I have the following.
<% @users.each do |user| %>
<% if user.pending_friends %>
<%= form_tag @user.accept_request(user), method: :post, remote: true do %>
<%= button_tag 'Accept Friend Request', class: 'btn btn-primary' %>
<%= form_tag @user.decline_request(user), method: :post, remote: true do %>
<%= button_tag 'Deny Friend Request', class: 'btn btn-primary' %>
<% end %>
<% end %>
and the first form tag throws
undefined method `update' for nil:NilClass
the controller is bellow
class FriendsController < ApplicationController
before_action :set_user, :authenticate_user!
respond_to :js
def show
@users = User.near(@user.address, 30)
@user = current_user
end
def update
end
private
def set_user
@user = current_user
end
end
I can submit a PR for documentation once I know what the proper implementation use
To me, your use of form_tag
looks incorrect. I think the first argument should be url_for_options
. (see here). Rather than supplying @user.accept_request(user)
as the first argument to your form_tag
, I think you want to use it in your controller.
Let me know if you already solved this.
I guess this issue has been solved by Branton and it does not relate the gem itself so I will close it.