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

This commit is contained in:
Alan Bradburne 2012-02-23 11:35:34 +00:00
parent 4f0354303f
commit 94b73faf85
2 changed files with 7 additions and 2 deletions

View File

@ -38,7 +38,7 @@ class ChannelsController < ApplicationController
# 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 File

@ -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 @@ class Channel < ActiveRecord::Base
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