Permalink
Browse files

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

  • Loading branch information...
1 parent 4f03543 commit 94b73faf85bcc449694b9011ed084247d7808ff6 @abradburne abradburne committed Feb 23, 2012
Showing with 7 additions and 2 deletions.
  1. +1 −1 app/controllers/channels_controller.rb
  2. +6 −1 app/models/channel.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
@@ -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

0 comments on commit 94b73fa

Please sign in to comment.