Re: session question..

Jay Pangmi
Sun, 12 Oct 2008 11:53:49 -0000

Jay Pangmi wrote:
> Ok, Now as I''ve made session[:cart_ids] and array with:
>
> session[:cart_ids] ||= []
>
> how can I clear all the stored ids in the session coz
> ''session[:cart_ids] = nil'' isn''t working. Also
as I have ids in the
> array referenced by session[:cart_ids] and that the carts table only
> stored the camp location, to get the id of each camp location stored in
> the cart, I''m doing:
>
> @cart=Cart.find(session[:cart_ids])
>
> for item in @cart
>  @camp_id=Campsite.find(:all, :conditions => [''camp_location =
> ?'',item.campsite])
>  Booking.create(......,:camp_id => @camp_id.id)
> end
>
> But, it doesn''t seem to work. Any better way? plz suggest me..
thanks.

session[:cart_ids].clear gives error as well instead. In case of the for
loop the when done as:
--------------------------------------------------------------------------------
@camp_id = Campsite.find(:all, :select => ''id'', :conditions
=>
[''camp_location = ?'',item.campsite])
Booking.create(....,:camp_id => @camp_id)
--------------------------------------------------------------------------------
No matter which campsite I select, 1 is saved as an id in camp_id column
in bookings table.. plz any suggestion?? thanks
I