My first 'acts_as' plugin

Written by Piers Cawley on , updated

So, you’ve upgraded to Rails 1.2.1 and you’re working on a tool to maintain a database of all the tunes you have in your various songbooks and (eventually) your record collection. You start with: $ ./script/generate rspec_resource MusicBook title:string author_id:integer \ abstract:text $ ./script/generate rspec_resource Tune title:string composer_id:integer \ abc:text book_id:integer You decide to come back to composers and authors later, so you set up your models[1]: MusicBook.has_many :tunes Tune.belongs_to :music_book

So, you’ve upgraded to Rails 1.2.1 and you’re working on a tool to maintain a database of all the tunes you have in your various songbooks and (eventually) your record collection. You start with:

$ ./script/generate rspec_resource MusicBook title:string author_id:integer \ abstract:text $ ./script/generate rspec_resource Tune title:string composer_id:integer \ abc:text book_id:integer

You decide to come back to composers and authors later, so you set up your models[1]:

MusicBook.has_many :tunes Tune.belongs_to :music_book

And your routes:

map.resource :music_books do |book| book.resource :tunes end

Problems start here

Being a cautious sort, before you start adding behaviour, you fire up a development server and go and check things with the browser. The /music_books/ stuff works fine, but once you start looking at /music_books/1/tunes things start to get weird; all of a sudden your links aren’t making sense.

  • 0 likes
  • 0 reposts
  • 0 replies
  • 0 mentions