title: No route matches {:action=>"update", :controller=>"" - Rails 5
body: <p>I am getting the below error and unsure how to correct it - your help would be much appreciated.</p>
  
  <p>when at a users show page, i do not get the error, but when at for example at any other page...such as the events index.html page the error displays</p>
  
  <pre><code>No route matches {:action=&gt;"update", :controller=&gt;"friendships", :friend_id=&gt;#&lt;User id: 5, email: "ian@gmail.com"
  </code></pre>
  
  <p>expanded error in terminal</p>
  
  <pre><code>Started GET "/events" for ::1 at 2016-12-17 12:44:43 +0000
  Processing by EventsController#index as HTML
    User Load (0.1ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ?  ORDER BY "users"."id" ASC LIMIT 1  [["id", 4]]
    User Load (0.1ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 4]]
    User Load (0.3ms)  SELECT  "users".* FROM "users" WHERE "users"."email" IS NULL LIMIT 1
    Subscription Load (0.1ms)  SELECT  "subscriptions".* FROM "subscriptions" WHERE "subscriptions"."title" = ? LIMIT 1  [["title", "premium"]]
    User Load (0.1ms)  SELECT "users".* FROM "users" INNER JOIN "friendships" ON "users"."id" = "friendships"."friend_id" WHERE "friendships"."user_id" = ? AND "friendships"."status" = ?  [["user_id", 4], ["status", "requested"]]
     (0.2ms)  SELECT COUNT(*) FROM "users" INNER JOIN "friendships" ON "users"."id" = "friendships"."friend_id" WHERE "friendships"."user_id" = ? AND "friendships"."status" = ?  [["user_id", 4], ["status", "requested"]]
    Rendered shared/_content_dropdownbox_friendrequest.html.erb (4.8ms)
    Rendered shared/_header.html.erb (10.7ms)
    Rendered events/index.html.erb within layouts/application (11.8ms)
  Completed 500 Internal Server Error in 23ms
  
  ActionController::UrlGenerationError - No route matches {:action=&gt;"update", :controller=&gt;"friendships", :friend_id=&gt;#&lt;User id: 5, email: "ian@gmail.com", encrypted_password: "$2a$10$PMO5FPBzjjnFHI/ye8rfP.ONtHP3gagXomj1sbruBXH..."
  </code></pre>
  
  <p>route file</p>
  
  <pre><code>Rails.application.routes.draw do
  
    resources :friendships,   only: [:create, :update, :destroy]
  
    devise_for :users
    resources :users
  end
  </code></pre>
  
  <p>views/shared/_content_dropdownbox_friendrequest.html.erb</p>
  
  <pre><code>&lt;ul&gt;
    &lt;% current_user.requested_friends.each do |requester| %&gt;
      &lt;li&gt;
        &lt;%= link_to(image_tag(requester.image_url, :alt =&gt;  "image", :class =&gt;"#", id: ""), user_path(requester)) %&gt;
        &lt;%= link_to truncate("#{requester.firstname} #{requester.lastname}", length: 23), user_path(requester) %&gt;
        &lt;%= link_to 'Accept', friendship_path(user_id: current_user, friend_id: requester), controller: "friendships", action: "update", method: :put %&gt;
        &lt;%= link_to 'Decline', friendship_path(user_id: current_user, friend_id: requester), controller: "friendships", action: "decline", method: :delete %&gt;
      &lt;/li&gt;
      &lt;div class="clear"&gt;&lt;/div&gt;
    &lt;% end %&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>frienships_controller</p>
  
  <pre><code>class FriendshipsController &lt; ApplicationController
    before_action :authenticate_user!
    before_filter :setup_friends
  
    # Sends a friend request.
    # We'd rather call this "request", but that's not allowed by Rails.
    def create
      Friendship.request(@user, @friend)
      flash[:notice] = "Request sent."
      redirect_to :back
    end
  
    # Accepts a friend request.
    # We'd rather call this "accept", but that's not allowed by Rails.
    def update
      @user = User.friendly.find(params[:user_id])
      @friend = User.friendly.find(params[:friend_id])
      if @user.requested_friends.include?(@friend)
        Friendship.accept(@user, @friend)
        flash[:notice] = "Connection with #{@friend.firstname} accepted!"
      else
        flash[:notice] = "No connect request from #{@friend.firstname}."
      end
      redirect_to :back
    end
  
    def destroy
      @user = User.friendly.find(params[:user_id])
      @friend = User.friendly.find(params[:friend_id])
      if @user.requested_friends.include?(@friend) #decline
        Friendship.breakup(@user, @friend)
        redirect_to :back
      elsif @user.pending_friends.include?(@friend) #cancel
        Friendship.breakup(@user, @friend)
        redirect_to :back
      elsif @user.friends.include?(@friend) #delete
        Friendship.breakup(@user, @friend)
        redirect_to :back
      end
    end
  
    private
    def setup_friends
      @user = User.find(current_user.id)
      @friend = User.find_by_email(params[:id])
    end
  end
  </code></pre>
  
  <p>i am unsure how to solve the error, i tried something like the below but does not work:</p>
  
  <pre><code>&lt;span&gt;
    &lt;%= form_for friendship, url: friendship_path(requester), method: :put do |f| %&gt;
      &lt;%= f.hidden_field :user_id, value: current_user.id %&gt;
      &lt;%= f.hidden_field :friend_id, value: requester.id %&gt;
      &lt;%= submit_tag "Accept_test", controller: "friendships", action: "update", class: "btn btn_add_friend" %&gt;
    &lt;% end %&gt;
  &lt;/span&gt;
  </code></pre>