[code] gs = if privates self.privates # with named_scopes everything runs fine else self.all # here we won't get a NamedScope, instead it'll be an Array end [/code] Try: [code] gs = if privates self.privates else self end [/code]
在 2009/11/9 下午 7:35 時, Joaquin Rivera Padron 寫到: > hi there, > I have a method in a model that concatenates named_scopes at later > points in the method if certain conditions given. The concatenations > go ok when all that concatenation is done with named_scopes, but it > blows when ActiveRecord.all is used in it > > see it in the gist: http://gist.github.com/229884 > > I could of course write that in some other way, but the question > would be: could AR.all be turned into a NamedScope and not an Array? > > any ideas? in the mean time I will refactor my code and make my > specs happy :-) > > cheers, > joaquin > > > > HeChian Hsu hechian...@gmail.com --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---