On 20/04/2012, at 9:30 PM, Jon Leighton wrote: > On 20/04/12 12:21, Dmytrii Nagirniak wrote: >>>> Hi, >>>> >>>> A quick question: in the query `Company.where(:status => :active)`, is it >>>> OK to use the symbol (:active) as a value in the query? >>>> >>>> It definitely works with no issues at all. >>>> >>> I'm not sure I'd consider it a public stable API, but if it works, go wild >>> :). >> >> So it is not a public API and the symbols were not supposed to be used this >> way? RIght? > > It's not really good Ruby style. See > http://blog.hasmanythrough.com/2008/4/19/symbols-are-not-pretty-strings
Do you mind to explain why exactly? I get the difference between strings and symbols, but in the example of "status" the string is definitely a wrong candidate to me. It is "internal" to the system. Although I understand and ok with converting it to a string to query, I don't see why symbol isn't good in this case (`company.status == :active`). > However I think we'd probably have to add specific code to make it *not* > work, so it will probably continue to work in the future. But I wouldn't > recommend doing it. I think you guys have settled that symbols are not "officially supported" here https://github.com/ernie/squeel/issues/67#issuecomment-5270896 So I'll take it for granted. Thanks a lot for the help. Cheers. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" 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-core?hl=en.
