Thursday, September 22, 2016

Rails: Dynamically Chain Scopes to Clean up SQL Queries

One of the worst things that can happen to a Rails application is SQL queries becoming a huge complex conditional mess. I have come across controller actions that build query strings using a type of “chain of conditionals” method, like so: sql = "active= 1" if condition sql += "and important=1" end if second_condition sql […]

Continue reading %Rails: Dynamically Chain Scopes to Clean up SQL Queries%


by William Kennedy via SitePoint

No comments:

Post a Comment