title: How to manage multiple Subscriptions using one controller action?
body: <p>I have following subscription creating system, right now when I`m selection available subscription groups(Marketing, Sales) action <code>Save Subscription</code> create this two subscriptions:</p>
  
  <pre><code>@apps = App.all
  if request.post?
    if params[:subscription] and params[:subscription][:app_id]                       
      params[:subscription][:app_id].each do |app_id|                
        Subscription.create_unique({user_id: current_user.id, app_id: app_id, approved: true})
      end
      redirect_to root_path
    end
  end
  @subscriptions = current_user.subscriptions 
  </code></pre>
  
  <p>So I can only add new <code>Subscriptions</code>(in this particular example i can only add <code>Engineering</code>)</p>
  
  <p><img src="https://i.stack.imgur.com/5VoyD.png" alt="Subscriptions"></p>
  
  <p>How to refactor that action to be able also destroy subscription groups by uncheck them(ex. I want to unsubscribe from Marketing group) ?</p>
  
  <p>So when I choose <strong>Marketing</strong> and <strong>Enginnering</strong> then <code>params[:subscription][:app_id]</code> will be equal <code>[marketing.id, engineering.id]</code></p>
  
  <pre><code>  # app_menu.html.erb
    &lt;%= form_for :subscription do |f| %&gt; # this form goes to app_menu action above
      &lt;ul&gt;
          &lt;% @apps.each do |app| %&gt;
          &lt;li&gt;
              &lt;%= check_box_tag app.id, current_user.access?(app) %&gt;&lt;span&gt;&lt;%= app.name %&gt;&lt;/span&gt;
          &lt;/li&gt;
          &lt;% end %&gt;
      &lt;/ul&gt;
      &lt;%= f.submit %&gt;
      &lt;% end %&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p>Relations:</p>
  
  <pre><code>App
    has_many :subscriptions
    has_many :users, through: :subscriptions
  User
    belongs_to :app
    has_many :subscriptions, :dependent =&gt; :destroy
  Subscription
    belongs_to :user
    belongs_to :app
  
    def self.create_unique(p)
      s = Subscription.find :first, :conditions =&gt; ['user_id = ? AND app_id = ?', p[:user_id], p[:app_id]]
      Subscription.create(p) if !s
    end
  </code></pre>
  
  <p>Schema</p>
  
  <pre><code># == Schema Information
  #
  # Table name: subscriptions
  #
  #  admin      :boolean
  #  app_id     :integer
  #  created_at :datetime
  #  id         :integer          not null, primary key
  #  updated_at :datetime
  #  user_id    :integer
  #
  # Table name: apps
  #
  #  created_at :datetime
  #  id         :integer          not null, primary key
  #  name       :string(255)
  #  updated_at :datetime
  #  user_id    :integer
  #
  # Table name: users
  #
  #  app_id     :integer
  #  created_at :datetime
  #  id         :integer          not null, primary key
  #  updated_at :datetime
  </code></pre>
  
  <p>So the issue is how to find which apps has been unchecked? </p>
  
  <p>Then remove subscription for them and remove Feeds using <code>Feed.app_destroy_items(app)</code></p>