Questions tagged [anonymous-scope]

3 questions
4
votes
1 answer

Can I create an *un*named scope in Rails?

I know you can create named scopes in Rails, which allow you to specify conditions which can then be built on later: named_scope :active, :conditions => {:active => true} ... MyModel.active.find(...) This works by creating a proxy object which…
Gareth
  • 133,157
  • 36
  • 148
  • 157
0
votes
1 answer

warning when using a named_scope as part of an anonymous scope

I have the following named scope: named_scope :find_all_that_match_tag, lambda { |tags| { :select => "articles.id, tags.name", :joins => :tags, :conditions => ["tags.name IN (?)",tags]} } It works fine…
0
votes
0 answers

Rails: Better understanding dynamic scopes

This is my "dynamic" scope: def all_games(conditions = {}) scope = games.includes(:stats).scoped {} scope = scope.where sport_position_id: conditions[:sport_position_id] unless conditions[:sport_position_id].nil? scope = scope.where…
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189