Move variables from session to ActiveRecord?

uhm sorry i don't get the actual problem, but before_filter surely is
the wrong place, plus in your above code @unit wasnt initialized in any
way, so its no ARObject of the Uni Model and has no method/attribute
"building_id"

class Unitcontroller < ...

def create
  @unit = Unit.new(params[:unit]) # if you have a hidden field with
name="unit[building_id]", the building_id will be assigned with this
command too.
  @unit.building_id = session[:building_id] # You can assign like this
from the session., if you dont want to use a hidden field.
  @unit.save
end
end

Hidden fields are more common for this type of thing imho..