Are there any books or resources which cover more advanced ActiveRecord queries, beyond just the nice methods we get in Rails, such as Model.association?
I need to learn more about joins across tables and conditions on them, I am fairly new to SQL and only really know the basics…
Should I just learn SQL? (If so do you know of any books aimed at noobs?) Or should I try to find books or resources that cover SQL from an ActiveRecord perspective (because I only really envisage myself using Rails – at least for the foreseeable future).
(If it’s any help I am using Postgres with my Rails apps)
ActiveRecord is abstraction (it is an ORM). As with all abstractions in programming the more you know about what is “under the hood” the better you will be. Understanding SQL goes along way toward making complex joins or even simple things like when and when not to add an index.
I would pick up a good book on SQL. If you’re using mySQL I like checkout http://oreilly.com/ they have some great books on mySQL and SQL in general. Postgres is a lot more strict then mySQL following the SQL standards. In my experience I enjoyed learning mySQL first, then learning Postgres differences.