Added routes, display seems to work so long as you remove the forms from the views.
[feedcatcher.git] / app / models / feed_item.rb
1 class FeedItem < ActiveRecord::Base
2
3 def self.in_feed(name)
4 where('feed_name = ?', name)
5 end
6
7 def self.entitled(title)
8 where('title = ?', title)
9 end
10
11 validates_presence_of :feed_name, :title, :description
12 validates_uniqueness_of :title, :scope => :feed_name
13 validate :feed_name_must_be_legal
14
15 def FeedItem.valid_feed_name?(feed_name)
16 Rack::Utils::escape(feed_name) == feed_name and
17 Rack::Utils::unescape(feed_name) == feed_name and
18 feed_name != 'index' and
19 feed_name != 'show' and
20 feed_name != 'update' and
21 feed_name != 'action'
22 end
23
24 private
25
26 def feed_name_must_be_legal
27 unless FeedItem.valid_feed_name?(feed_name)
28 errors.add(:feed_name, 'is invalid')
29 end
30 end
31 end