Forum: Ruby on Rails Remove item from session

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
187430a61a620c98e7548ef016a53a6d?d=identicon&s=25 Michel Dogger (micheldogger)
on 2006-06-12 15:15
Hello,

i'm struggling with the following problem: I have a edit page wich
on wich a user can edit his Account information and add or remove
his Subscriptions. For the time the user is editing his Subscriptions
I'll keep his subscriptions in a session. After the user has finished
adding and removing subscriptions I want to have the new set of
subscriptions
in the session. If the user validates his modifications, i'll write the
modifications to the database.

I have the following code in my accounts_controller

def edit
  @account = Account.find(params[:id])
  @subscriptions = @account.subscriptions
  session[:subscriptions] ||= Subscription.new
  session[:subscriptions] = @subscriptions
end

the session[:subscriptions] contains all the subscriptions that
belong to a specific account.

i.e.

Account 1 has the following Subscriptions

1.. Subscription 1
2.. Subscription 2
3.. Subscribtion 4
4.. Subscribtion 7

My problem:
If the user click on de 'Delete' url for example on Subscription 4, i
want to
remove subscription 4 from the session. (So i don't want to remove
that object fysically from the database). Does anybody know how to
do that?

micheldogger
This topic is locked and can not be replied to.