Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Change clear channel to not do a find-all before deleting feeds.

  • Loading branch information...
commit 94b73faf85bcc449694b9011ed084247d7808ff6 1 parent 4f03543
@abradburne abradburne authored
Showing with 7 additions and 2 deletions.
  1. +1 −1  app/controllers/channels_controller.rb
  2. +6 −1 app/models/channel.rb
View
2  app/controllers/channels_controller.rb
@@ -38,7 +38,7 @@ def create
# clear all data from a channel
def clear
channel = current_user.channels.find(params[:id])
- channel.feeds.delete_all
+ channel.delete_feeds
channel.update_attribute(:last_entry_id, nil)
redirect_to channels_path
View
7 app/models/channel.rb
@@ -10,6 +10,7 @@ class Channel < ActiveRecord::Base
after_create :set_initial_default_name
before_validation :set_default_name
+ after_destroy :delete_feeds
validates :name, :presence => true, :on => :update
@@ -22,7 +23,11 @@ def add_write_api_key
end
def field_label(field_number)
- self["field#{field_number}"]
+ self.attributes["field#{field_number}"]
+ end
+
+ def delete_feeds
+ Feed.delete_all(["channel_id = ?", self.id])
end
private
Please sign in to comment.
Something went wrong with that request. Please try again.