Common variable.

Hey Everyone,

At the bottom of my site layout I have a suggested item box. This box
is at the bottom of everypage but the admin/manage section.

I tried using:

class ApplicationController < ActionController::Base
    @mightlike = Vehicle.random

then in the view for vehicles:

// vehicles.html.erb
<dt>Make:</dt><dd><%=h @mightlike.make %></dd>

It works fine if i add "@mightlike = Vehicle.random" in:

class VehiclesController < ApplicationController
  def index
    @vehicles = Vehicle.find_all_by_market_status('available')
    @mightlike = Vehicle.random

But that restricts it to the index on the vehicle controller and I
need it in almost every view being controlled by every controller.
Whats the best way to do that?

Try a before_filter. In your ApplicationController add the following:

    before_filter :load_mightlike

      def load_mightlike
        @mightlike = Vehicle.random

Darian Shimy

worked perfect, thank you kindly =)