I'm a beginner (hobbyist) Rails developer. I've gone through many of the available tutorials, such as Michael Hartl's excellent Ruby on Rails Tutorial at http://ruby.railstutorial.org/ (both editions, books, and screencasts). I can build and understand simple CRUD-type applications with associations with no problems.
Now, I want to "scratch my own itch" and build an application I can actually use in my work. Basically, it will need to be able to keep track of tasks and comments arranged as projects and project templates. I'm running into difficulty designing these models and associations because they are more complex. I'm sure I could find or buy an application to do this, but I'd really like to learn how to do it myself, instead.
Question: Are there techniques or resources (books, tutorials, articles) or forums where I can learn to design more complex models and associations? This doesn't seem like it's specific to Rails (to me). Should I be researching database techniques, models, associations, for example, to get ideas?
One, the book Enterprise Rails. It's a few years old, so all the examples are from Rails 2, but the meat of it is about proper database design, including the stuff that Rails doesn't believe in (composite primary keys, foreign key constraints, check constraints, triggers). Chapter 4, about the importance of data integrity, was probably the single most useful thing I've read about web development in the past few years.
Most of it is on Google Books (although sadly, chunks of chapter 4 are missing): http://books.google.com/books?id=thTju-4duY4C&printsec=f...
Second, the best thing I did was replace ActiveRecord with Sequel. Sequel has built-in support for all of those things that ActiveRecord doesn't (I couldn't live without its composite primary key support), and is in general a much more robust library than ActiveRecord. It also supports more exotic SQL features like CTEs and CASE statements without forcing you to drop down to writing raw SQL (though you can certainly do that if you want).
It's not a necessary upgrade for everyone. If your app has fairly simple models and relationships, ActiveRecord will probably be just fine for you. But if you want to get better with SQL and get closer to your DB, I think Sequel is a much better choice.
More info on Sequel: http://sequel.rubyforge.org/
It also integrates very well with Postgres - there's a C extension for the Sequel postgres adapter (https://github.com/jeremyevans/sequel_pg) and support for adding common triggers in migrations, counter columns and whatnot (https://github.com/jeremyevans/sequel_postgresql_triggers). It also supports the more exotic datatypes - hstore, arrays, even the json and range types that are coming in PG 9.2.