Cannot modify association 'User#tracks' because it goes through more than one other association
<p>I created a Playlist association so Users can add a track to a playlist if they chose. That works, the problem is, a user now cannot upload a track the normal way through <code>belongs_to :user</code></p>

<p>Something in my association broke the relationships and I can't figure out what it is, here's all of the relevent code from my models:</p>

<pre><code>class User &lt; ActiveRecord::Base
require 'soundcloud'
acts_as_voter
belongs_to :gallery
has_many :tracks



has_many :active_relationships, class_name:  "Relationship",
                              foreign_key: "follower_id",
                              dependent:   :destroy

has_many :passive_relationships, class_name:  "Relationship",
                               foreign_key: "followed_id",
                               dependent:   :destroy                                

has_many :following, through: :active_relationships, source: :followed
has_many :followers, through: :passive_relationships, source: :follower

has_many :playlists
has_many :tracks, through: :playlists
end
</code></pre>

<p>--</p>

<pre><code>class Playlist &lt; ActiveRecord::Base
belongs_to :user
has_many :playlist_tracks
has_many :tracks, through: :playlist_tracks
end
</code></pre>

<p>--</p>

<pre><code>class PlaylistTrack &lt; ActiveRecord::Base
belongs_to :playlist
belongs_to :track
end
</code></pre>

<p>--</p>

<pre><code>class Track &lt; ActiveRecord::Base
acts_as_votable
belongs_to :user

has_many :playlist_tracks

has_many :playlists, through: :playlist_tracks

mount_uploader :track, TrackUploader

validates :title, presence: true
validates :description, presence: true
validates :track, presence: true
validates_length_of :title, :minimum =&gt; 2, :too_short =&gt; "please enter at least %d character"
validates_length_of :description, :minimum =&gt; 10, :too_short =&gt; "please enter at least %d characters"


def self.search(query)
# where(:title, query) -&gt; This would return an exact match of the query
where("title || description like ?", "%#{query}%")
end
end
</code></pre>

<p>Please let me know if I should clarify anything about the issue, thanks.</p>

<p>EDIT: </p>

<p>ERROR: Cannot modify association 'User#tracks' because it goes through more than one other association.</p>

<p>The error points to the create action in the tracks_controller.rb</p>

<pre><code>class TracksController &lt; ApplicationController
skip_before_filter  :verify_authenticity_token
def show
    @track = Track.find_by(id: params[:id])
end

def new
    @user = User.find(params[:user_id])
    @track = Track.new
end

def create
    @user = current_user
    @track = @user.tracks.create(track_params)

    if @track.save
        redirect_to user_path(current_user)
    else
        redirect_to :back
        flash[:alert] = 'There was an error processing your request'
    end
end

def upvote 
  @track = Track.find_by(id: params[:id])
  @track.upvote_by current_user

  render json: @track
end  

def unvote
  @track = Track.find_by(id: params[:id])
  @track.unliked_by current_user

  render json: @track
end

 def likes
    @user = User.find_by(id: params[:id])
    @likes = @user.find_voted_items

    render json: @likes
 end



 private

 def track_params
   params.require(:track).permit(:track, :user_id, :title, :description, :artist)
 end

 end
</code></pre>

<p>UPDATE: When I remove like 7 in the user model it doesn't give me an error but that track does not save...</p>