Forum: Ruby on Rails How to get which check boxes has beed unchecked and remove Subscription for them?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
B39eadf04a0382f9d9ebd715669e53aa?d=identicon&s=25 Darek F. (darek_f)
on 2012-11-07 00:28
(Received via mailing list)
I have following subscription creating system, right now when I`m
available subscription groups(Marketing, Sales) action Save Subscription
create this two subscriptions:

@subscriptions = current_user.subscriptions
> @apps = App.all
> if
>   if params[:subscription] and params[:subscription][:app_id]
>     params[:subscription][:app_id].each do |app_id|
>       Subscription.create_unique({user_id:, app_id:
> app_id})
>     end
>     redirect_to root_path
>   end
> end

# app_menu.html.erb

<%= form_for :subscription do |f| %> # this form goes to app_menu action
> above
      <% @apps.each do |app| %>
        <li> <%= check_box_tag, current_user.access?(app)
           <%= %></span>
      <% end %>
  <%= f.submit %>
<% end %>

So I can only add new Subscriptions(in this particular example i can
add Engineering).


How to refactor that action to be able also destroy subscription groups
uncheck them(ex. I want to unsubscribe from Marketing group) ?

So when I choose Marketing and Enginnering then
params[:subscription][:app_id] will be equal [,]


>  has_many :subscriptions
>  has_many :users, through: :subscriptions
> *User*
>  belongs_to :app
>  has_many :subscriptions, :dependent => :destroy
> *Subscription*
>  belongs_to :user
>  belongs_to :app

So the issue is how to find which apps has been unchecked? And maybe is
way how to refactor that action. Pleas help :)
This topic is locked and can not be replied to.