Search
Categories
- Deployment (4)
- Development (63)
- Gems and Plugins (4)
- News (2)
- Projects (4)
- Testing (3)
Most Popular Tags
activerecord architecture collections css database date and time debugging design design patterns DRY ebooks fixtures floating-point numbers formatting framework front page global variables helpers I18n introductory launchpad meta-information migrations model multiplicity mvc MySQL partials production rails 2.0 rails 2.1 Rails 2.2 regular expressions routing rss ruby security setup sql UI upgrading user management validation xml xml builder
Tag Archives: sql
Rails 2.1: Aggregate Expressions
Rails 2.1 allows you to perform complex aggregate queries, such as Donation.sum(“amount * 3″). This makes complex calculations a snap! Rails provides functions for calculating the average, count, maximum, minimum, and the sum. Continue reading
Find_by_SQL
How can you use the find function if you have complex find criteria–such as searching by fields that don’t exist in the table for your class? Enter the find_by_sql function. It allows you to use arbitrary SQL to find the model records you want–everything from joins and where clauses to having clauses. Rails handles the nitty-gritty work of returning models that have the attributes you selected. Continue reading
Using SQL for complex SELECT/ORDER Criteria
How can you select model objects using a complex SQL criterion (such as ordering by a SUM of values)? The answer is to use the find_by_sql method. You can select complex fields, join tables, and sort on those fields–such as sum fields. Continue reading