Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
## 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 => <name>'. 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'
This paste will be private.
From the Design Piracy series on my blog: