Set up the feed_item model
[feedcatcher.git] / app / models / feed_item.rb
1 class FeedItem < ActiveRecord::Base
2 validates_presence_of :feed_name, :title, :description
3 validates_uniqueness_of :title, :scope => :feed_name
4 validate :feed_name_must_be_legal
5
6 def FeedItem.valid_feed_name?(feed_name)
7 Rack::Utils::escape(feed_name) == feed_name and
8 Rack::Utils::unescape(feed_name) == feed_name and
9 feed_name != 'index' and
10 feed_name != 'show' and
11 feed_name != 'update' and
12 feed_name != 'action'
13 end
14
15 private
16
17 def feed_name_must_be_legal
18 unless FeedItem.valid_feed_name?(feed_name)
19 errors.add(:feed_name, 'is invalid')
20 end
21 end
22 end