While I love playing it it goes to show that:
- I'm monodextrous
- I lack rhythm
- I have zero hand-eye co-ordination
This blog will be a generous mix of rants and geeky information that I couldn't find a decent web reference for so I had to work it out myself. If you're not interested in something, I'd recommend you subscribe using the categories on the right.
Details are at:
https://bugzilla.mozilla.org/show_bug.cgi?id=92111
Done
The way I see it there were three possible reasons for why:
(1) The guy didn't notice the big ambulance with flashing lights and sirens;
(2) The guy did notice it but chose maliciously not to get out of the way;
(3) The guy did notice but didn't want to go through the red-light-camera and have to somehow convince the powers that be that he did it for a good reason.
I know what I think is most likely.
class Author < ActiveRecord::BaseWhat's missing is the background stuff, how to get here, and what the DB needs to look like for this to work. The belongs_to association implies that the table associated with the object (eg Authorship) contains a foreign-key for that object. In this case the table "authorships" must have columns with foreign-keys for book and author. In the normal rails setup this means two columns called book_id and author_id.
has_many :authorships
has_many :books, :through => :authorships
end
class Authorship < ActiveRecord::Base
belongs_to :author
belongs_to :book
end
./script/generate model Authorship
./script/generate model Book
./script/generate model Author
...You can add any columns you want to the migration definitions for the other tables (names would be obvious) but bear in mind that there will (if you don't do anything special) be a hidden primary-key defined for each one as if you included the line:
create_table :authorships do |t|
t.column :author_id, :integer # foreign key for author
t.column :book_id, :integer # foreign key for book
end
...
t.column :id, :integerYou don't need to add any external references to either the books or authors table.
rake db:migrate(you can choose any given version of your DB by appending VERSION=N to the line above - N corresponds to the nnn_prefix as above).
# Test the books relationship works as expected using the test data defined in fixturesRun your test using:
def test_fixtures_books_relationship
author = Authors.find(1) # grab the author you defined with id: field of 1
assert author # ensure author was found
assert_equals 2, author.books.length # check the authorship connections
# you defined in your fixtures
book_names = ["Some book", "Another Book"]
author.books.each do |book|
assert book_names.find(book.name) # ensure that each of the books was
# one of the two expected
end
end
rake test:units