Change clear channel to not do a find-all before deleting feeds.
This commit is contained in:
parent
4f0354303f
commit
94b73faf85
@ -38,7 +38,7 @@ class ChannelsController < ApplicationController
|
|||||||
# clear all data from a channel
|
# clear all data from a channel
|
||||||
def clear
|
def clear
|
||||||
channel = current_user.channels.find(params[:id])
|
channel = current_user.channels.find(params[:id])
|
||||||
channel.feeds.delete_all
|
channel.delete_feeds
|
||||||
channel.update_attribute(:last_entry_id, nil)
|
channel.update_attribute(:last_entry_id, nil)
|
||||||
|
|
||||||
redirect_to channels_path
|
redirect_to channels_path
|
||||||
|
@ -10,6 +10,7 @@ class Channel < ActiveRecord::Base
|
|||||||
|
|
||||||
after_create :set_initial_default_name
|
after_create :set_initial_default_name
|
||||||
before_validation :set_default_name
|
before_validation :set_default_name
|
||||||
|
after_destroy :delete_feeds
|
||||||
|
|
||||||
validates :name, :presence => true, :on => :update
|
validates :name, :presence => true, :on => :update
|
||||||
|
|
||||||
@ -22,7 +23,11 @@ class Channel < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def field_label(field_number)
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
Loading…
Reference in New Issue
Block a user