Its just an additional class that i need to create
objects for use within my controller, any ideas??
If you create a class and put it in lib/, you'll be able to access it
from anywhere in your application - including controllers.
Just name the file after the class name i.e. MyClass should be in lib/
my_class.rb. If you're using 1.2, rails will include the file
automatically. If you're still on an earlier version, you'll need to
add a require line in yourself in environment.rb (require 'my_class').
Hope that helps,
Steve
where this
'setup' method should be within my rails directory structure?
What I would do is add a before_filter to your ApplicationController:
class ApplicationController < ActionController:Base
before_filter :setup
private
def setup
if !session[:my_variable]
# get data and edit session
end
end
end
Just to note, you should use the 'session' method to access the
session data rather than the instance variable '@session'. You should
also consider whether or not you really need to store objects in the
session as it can cause issues. It's best to keep the session small
if you can.
Hope that helps,
Steve