Ruby On Rails: Using parameters from the new controller function in the create controller function
===

I'm passing in :number as a parameter and then assigning it to the variable @test_suite_num in the controller in the `before_filter`. 

In my `new` function in the controller, I use the variable @test_suite_num to filter a table named `Test` to get the count of entries whose id's match @test_suite_num. I use this count to generate the appropriate number of child resources `test_run`.

I do the same for `create` but for some reason I get nil errors whenever I use these variables in the forms that rely on the `@test_suite_num`. I am assuming that since create never takes a parameter, the variable is never initialized. How can I use @test_suite_num in the `create` function?

Controller Code:

    before_filter :get_number, :only => [:new, :create]

    def get_number
        @test_suite_num = params[:number]
    end


New

    def new
        @test_suite_run = TestSuiteRun.new
        
        @tests = Test.find(:all, :conditions => { :test_suite_id => @test_suite_num })
        
        @tests.count.times do test_run = @test_suite_run.test_runs.build end
    end

Create
      
    def create
        @test_suite_run = TestSuiteRun.new(params[:test_suite_run])
        
        @tests = Test.find(:all, :conditions => { :test_suite_id => @test_suite_num })
        
        @tests.count.times do test_run = @test_suite_run.test_runs.build(params[:test_suite_run]) end
        
        if @test_suite_run.save
            flash[:success] = "Run Added Succesfully"
            redirect_to test_suite_runs_path(@test_suite_run)
            else
            render 'new'
        end
    end