Rails 4 Error: ActiveRecord::RecordNotFound Couldn't find id=
<p>I'm fairly new to rails and into coding my first app. Just can't figure out how to target a user the current_user favorited (Three models: User, Tool, FavoriteUser).</p>

<p>Controller (Tools)</p>

<pre><code>def index
  @favorites = current_user.favorites.order("created_at DESC")
  @userfavorites = current_user.userfavorites.order("created_at DESC")
  @tools = Tool.where(user_id: current_user).order("created_at DESC")
  @user = current_user.favorite_user # problematic!
  @cuser = current_user
end
</code></pre>

<p>Index View (Tools)</p>

<pre><code>%h2 My Favorite Users
- @userfavorites.each do |user|
    = image_tag gravatar_for @user if @user.use_gravatar == true
    = image_tag @user.avatar_filename.url if @user.use_gravatar == false
    %h2= link_to @user.username, @user
    %p= link_to "Favorite", userfavorite_user_path(user, type: "favorite"), method: :get
    %p= link_to "Unfavorite", userfavorite_user_path(user, type: "unfavorite"), method: :get
</code></pre>

<p>If I run this in my browser it appears following error:</p>

<pre><code>NoMethodError in ToolsController#index
undefined method `favorite_user' for #&lt;User:0x39df638&gt;
</code></pre>

<p><strong>FavoriteUser Database:</strong></p>

<pre><code>user_id:integer #favorited
c_user_id:integer #active user
</code></pre>

<p>I simply can't figure it out.<br><br>
Thanks in advance for your help!</p>

<p><strong>RELATIONSHIPS:</strong></p>

<p><em>user.rb</em></p>

<pre><code>has_many :favorite_users # just the 'relationships'
  # Favorite users of user
  has_many :favorite_relationships, class_name: "FavoriteUser", foreign_key: "c_user_id"
  has_many :userfavorites, through: :favorite_relationships, source: :user

  # Favorited by a user
  has_many :favorited_relationships, class_name: "FavoriteUser", foreign_key: "user_id"
  has_many :userfavorited_by, through: :favorited_relationships, source: :c_user
</code></pre>

<p><em>favorite_user.rb</em></p>

<pre><code>class FavoriteUser &lt; ActiveRecord::Base
    belongs_to :c_user, class_name: "User"
    belongs_to :user, class_name: "User"
end
</code></pre>

<p><strong>ROUTES</strong></p>

<pre><code>Rails.application.routes.draw do
  devise_for :users

  get 'welcome/index'
  resources :tools do
    member do 
      get "like", to: "tools#upvote"
      get "dislike", to: "tools#downvote"
    end
    get :favorite, on: :member
  end

  resources :users, only: [:index, :show] do 
    get :userfavorite, on: :member
  end

  authenticated :user do
    root 'tools#index', as: "authenticated_root"
  end

  root 'welcome#index'

  get '/search' =&gt; 'tools#search'

  get '/users' =&gt; 'users#index'
end
</code></pre>