Report abuse

app/model/jokes.rb (snippit)


			
  has_many :taggings
  has_many :tags, :through => :taggings

app/model/taggings.rb


			
class Tagging < ActiveRecord::Base
  set_table_name "tags_jokes"

  has_many :taggings
  has_many :jokes, :through => :taggings

end

schema for tags_jokes


			
                                       Table "jj.tags_jokes"
   Column   |           Type           |                         Modifiers                          
------------+--------------------------+------------------------------------------------------------
 id         | integer                  | not null default nextval('jj.tags_jokes_id_seq'::regclass)
 joke_id    | integer                  | not null
 tag_id     | integer                  | not null
 user_id    | integer                  | not null
 created_at | timestamp with time zone | not null default now()

unit/joke_test.rb (snippit)


			
  def test_add_tag
    joke = Joke.find(30964)
    assert_equal 0, joke.tags.size      # line 117 from error message
    joke.tags << Tag.new(:name => "tagme")
    assert_equal 1, joke.tags.size
  end

Error


			
 1) Error:
test_add_tag(JokeTest):
ActiveRecord::HasManyThroughSourceAssociationNotFoundError: Could not find the source association(s) :tag or :tags in model Tagging.  Try 'has_many :tags, :through => :taggings, :source => '.  Is it one of :jokes or :taggings?
    /Users/donp/work/rails-dsr/config/../vendor/rails/activerecord/lib/active_record/reflection.rb:187:in `check_validity!'
    /Users/donp/work/rails-dsr/config/../vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb:6:in `initialize'
    /Users/donp/work/rails-dsr/config/../vendor/rails/activerecord/lib/active_record/associations.rb:926:in `tags'
    test/unit/joke_test.rb:117:in `test_add_tag'