title: How to remember a parameter value between pages in a controller
body: <p>I have managed to produce a series of three buttons on an index page enabling a user to identify a subset of the objects in a database - button 1 - type = "new", button 2 - type = "used", button 3 - no restriction i.e. can be new or used.</p>
  
  <p>Currently index.html.erb contains:</p>
  
  <pre><code>&lt;%= link_to "New", :controller =&gt; params[:controller], :action =&gt; params[:action],    :product_type =&gt; 'New' %&gt;
  &lt;%= link_to "Used", :controller =&gt; params[:controller], :action =&gt; params[:action], :product_type =&gt; 'Used' %&gt;
  &lt;%= link_to "Don't Restrict", :controller =&gt; params[:controller], :action =&gt; params[:action], :product_type =&gt; nil %&gt;
  </code></pre>
  
  <p>Within product.rb i have:</p>
  
  <pre><code>scope :by_product_type, lambda{|product_type| where(:product_type =&gt; product_type) unless product_type.nil? }
  </code></pre>
  
  <p>Finally I have productfinder_controller:</p>
  
  <pre><code>before_filter :load_grips, :only =&gt; [:index, :bybrand, :bycolour, :byprice]
  protected
  def load_products
  if params[:product_type]
    @productssmatchingtype = Product.by_product_type(params[:product_type])
  else
    @productsmatchingtype = Product
  end
  end
  </code></pre>
  
  <p>The above code works exactly as I hoped, loading all items initially and restricting them if Button 1 or Button 2 is pressed.</p>
  
  <p>I would also like to have similar functionality on 3 other pages within the Productfindercontroller, namely byprice, bybrand and bycolour.  I have put the same code as provided above in each of these 3 other .html.erb files and again things seem to be behaving...</p>
  
  <p>EXCEPT - When a new page is loaded the default is that all the products are shown, i.e. it has not remembered what button the user pressed on the previous page.  Is it possible to store the information regarding the button pressed somewhere which is accessible to all the pages in the controller?  Similarly / Alternatively, is it possible to define @productsmatchingtype (in productfinder_controller) in such a way that it is accessible to all the pages and doesn't need to start from scratch again?</p>