Question: no need for answer unless you feel you want to contribute :)

So I feel stupid as hell I been banging my head against a wall with this for an hour... 
but for the sake of your head ill explain the problem,
I had a mark-up that looks like this

```
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MainSearch.aspx.cs" Inherits="MainSearchNewDesign" %>

```

And code behind that looks like this :

```
public partial class MainSearchNewDesign : System.Web.UI.Page

```

And still I got that damn error, the reason for that is that I forgot that if I have the a different file ( with a different name ) with the same class name the compiler still takes into account and tells you to go bang your head onto the wall... 

Man I feel really stupid now... but I hope this will help someone.

Answer: 
This is a before filter

```
class YourController
  before_filter :filter_scopes, only: :index

  def index
    @campaigns = Campaign.send(params[:scope] || 'all')
  end

  private
  def filter_scopes
    params[:scope] = nil unless ['ended','active'].include?(params[:scope])
  end
end

```

that way you are sure that only "ended", "active" and "all" are the allowed values when calling the scope

EDIT: this is an old answer, I'd like to add that `before_filter` was replaced with `before_action` on newer rails versions. Also, I now think that there might be a more elegant solution for this without a before\_action and without changing the params hash, just add a "getter" for the scope value:

```
class YourController
  def index
    @campaigns = Campaign.send(get_scope_from_params)
  end

  def get_scope_from_params
    ['ended','active'].include?(params[:scope]) ? params[:scope] : 'all'
  end
end

```

You can even make it a helper method if you need to use it on the view. I think it's better not to modify params hash (unless you are sure that's what you want) and it also makes more sense to have a "getter" method than a before\_action method since what you actually want is to get a valid scope name.
You can whitelist your scopes, like this:

```
@campaigns = if %w(ended active).include?(params[:scope])
               Campaign.public_send(params[:scope])
             else
               Campaign.all
             end

```