Question: I am trying to create a scope for an Active Record model using rails 4. The scope deals with 2 conditions which I am able to execute individually:

1) `includes(:categories).for_category("proposal")`
2) `where(:is_published => true)`

I need a scope that returns all records where either condition is met (not necessarily both). So something like:

```
scope :proposal, -> { includes(:categories).for_category("proposal") || where(:is_published => true)}

```

Thanks for any help.

**\*\*EDIT\*\***

Per comment here is the definition of the for\_category scope taken from <https://github.com/comfy/comfortable-mexican-sofa/blob/b16bb14bec7bffee61949d72a5f2c9eca3c95bf8/lib/comfortable_mexican_sofa/extensions/is_categorized.rb>

```
scope :for_category, lambda { |*categories|
  if (categories = [categories].flatten.compact).present?
    self.distinct.
      joins(:categorizations => :category).
      where('comfy_cms_categories.label' => categories)
  end
}

```

Answer: 
You'll need to define a new scope which includes an sql "OR". I don't know what your "for\_category" scope is doing but let's say it's something like 

```
scope :for_category, ->(category_name) { where("categories.name" => category_name)}

```

Then you could make a new scope like this: note that the `where` arguments are a list of values rather than a hash (the hash form can only produce sql for `=` tests joined with `AND`)

```
scope :published_or_for_category ->(category_name){ includes(:categories).where("categories.name = ? OR proposals.is_published = ?", category_name, true) }

```
Based on Max's suggestions I got the following to work:

```
scope :published_or_for_category, ->(category_name){
  includes(:categories).where(
  "comfy_cms_categories.label = ? OR is_published = ?",
  category_name, true
  )
}

```

I might mention that the following seems to work as well:

```
scope :proposal, -> { includes(:categories).for_category("proposal") | where(:is_published => true) }

```

Is one better that the other?