This filters out rows where name is null and orders by name in SQL:
Category.where("name NOT NULL").order("name ASC")

I'm not sure how to get mysql to downcase the column, but I'm pretty sure 
there's a way.

Luke

On 2010-12-19, at 5:11 PM, Me wrote:

> Is there a relatively easy way to do this code in sql?
> 
> @categories=Category.all.reject{|n| n.blank?}.sort{|a,b| a.name 
> <=>b.name}.collect{|t| [t.name,t.name.downcase.gsub(' ','_')]}
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to