Kang Cao wrote in post #1110456:
> You should use 'where' if you are using rails 3. the find_by method is
> not suggested now. Hence your problem is easy to be resolved by
> "User.where(:age=>25)
Oh, yes, you're right. From Edge Guides:
Dynamic finders have been deprecated in Rails 4.0 and will be
removed in Rails 4.1.
I thought the other way around, that dynamic finders are better choice.
But the thing is that .find_by may return exactly a model object, but
.where returns ActiveRecord::Relation in all cases.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/aaf51a021d2463fc292250928a104b3e%40ruby-forum.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment