I’m getting this error undefined local variable or methodtoggle_follow_path’` in the view folder .I probably got something wrong with the method or the use off form_tag + toggle_follow_path any help would be welcome thank you . by the way the goal of the toggle follow is to follow or un follow some one.
in the route file
match '/:username/toggle_follow', to: 'home#toggle_follow'
home controller
def toggle_follow
@user = User.find_by_username(params[:username])
if current_user.is_friend? @user
flash[:notice] = "You are no longer following @#{@user.username}"
current_user.remove_friend(@user)
else
flash[:notice] = "You are now following @#{@user.username}"
current_user.add_friend(@user)
end
redirect_to user_flits_path(@user)
end
view
<h1><%= image_tag @user.gravatar_url, :align => "top" %> <%= @user.username %></h1>
<%= form_tag toggle_follow_path, :method => :post do %>
<% if current_user.is_friend? @user %>
<%=h submit_tag "Following" , :class => "button" %>
<% else %>
<%=h submit_tag "Follow" , :class => "button" %>
<% end %>
<% end %>
<%=h render :partial => "flits_list", :locals => {:flits => @flits }%>
Use
:asoption formatchto specify the desired helper’s name:This way both
toggle_follow_pathandtoggle_follow_urlwill be created.