ruby hash syntax fix, move SQL filtering to model