Thursday, March 17, 2011

[Rails] Help with session

oookk, so i have 2 actions , create and destroy, i can get
session[:cart_id] from inside the create method but not from inside
the delete method.

def create
@cart = current_cart
Rails.logger.debug "SESSION INFO HERE
#{session[:cart_id]}" this here is 18

.
.
.


def destroy
# @cart = current_cart
@line_item = LineItem.find(params[:id])
Rails.logger.debug "SESSION INFO HERE
#{session[:cart_id]}" this here is nil


.
.
.


here is how i create the cart


private
def current_cart
begin
Cart.find(session[:cart_id])
rescue ActiveRecord::RecordNotFound
Rails.logger.debug "SESSION IS #{session.inspect}" <==
is empty when i call it from the destroy method
cart = Cart.create
session[:cart_id] = cart.id
cart
end
end


anyone knows whats going on?

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate