How can I process important session information as if it were a model?
I started doing this, and some of them work. But I'm not sure what I am missing? Does anyone know a good place to start or where can I find good examples?
In addition, I can use the model to set session variables, but how to get them from the model, and not always use session [: blah] ... How can I get them from the model?
class Cart
attr_reader :items
def initialize(session)
@session = session
@session[:cart] ||= []
@items ||= session[:cart]
end
def add_rooms(new_rooms,startdate,days)
new_rooms.delete_if {|k, v| v == "0" }
rooms = []
new_rooms.each do |k, v|
rooms << {:room_id => k, :people => v, :no_days => days, :startdate => startdate}
end
@session[:cart] = rooms
end
end
source
share