Are you using MySQL? It has a field function that solves this

https://www.w3schools.com/sql/func_mysql_field.asp

You could probably do the same thing with substring index with other DBMSs.

On Thu, Oct 19, 2017 at 1:30 PM Pablo Margreff <pmargr...@gmail.com> wrote:

> I have a situation which I need use a specific order for queries which the
> attributes are an enum, something like this:
> *.order("x.status = 5, x.status = 1, x.status = 6 ...")*, but it isn't
> the best way for readability, and I haven't found anything about how to do
> it on rails way.
>
> Is a big deal create this functionality on rails? Something like:
> *.order(status: [:removed, :new, :active, :corrupted ...])*
>
> *If yes, it's something trivial, if a haven't contributed with rails, can
> I help to build that? *
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>
-- 
*Kevin D. Deisz*
Localytics Software Engineer

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to