Re: [Rails] Re: What is the actual use of ActiveRecord::SpawnMethods#except?



On Sunday, 6 July 2014 13:29:15 UTC-5, Arup Rakshit wrote:
> `except` is used when you want to use part of a relation but not
> necessarily the whole thing. It's not always useful in application code,
> but when dealing with generic relations it can be really useful:
>
> https://github.com/rails/rails/blob/44b7d6c41610bb8ddd058b3815543985f65bf7ad
> /activerecord/lib/active_record/relation/finder_methods.rb#L296
>
> Here, `except` is used to remove parts of the relation that `exists?`
> doesn't want to use.
>
> --Matt Jones

Very useful example. Does it mean, we can use it also *scope* or on *default
scope* ? Will it be a good choice although to use scope relation if it fits any
query, with some tailoring using *except* ?


Yep. There are also some related methods; `rewhere`, `reorder`, and `unscope`. They allow somewhat finer control than `except`.

--Matt Jones 

--
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/1ec7b74b-1779-4bf3-b6a1-87b66f46ccdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.