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

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to